Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Unified Diff: src/runtime/runtime-generator.cc

Issue 1010883002: Switch full-codegen from StackHandlers to handler table. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-isolate-dead-code
Patch Set: Fix debugger-pause-on-promise-rejection. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-generator.cc
diff --git a/src/runtime/runtime-generator.cc b/src/runtime/runtime-generator.cc
index 1dfd1b5735c66fd6e693fb50f5835026ea2ec319..d8b084431bad077521284d54ac2460d65161dd86 100644
--- a/src/runtime/runtime-generator.cc
+++ b/src/runtime/runtime-generator.cc
@@ -31,7 +31,6 @@ RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) {
generator->set_receiver(frame->receiver());
generator->set_continuation(0);
generator->set_operand_stack(isolate->heap()->empty_fixed_array());
- generator->set_stack_handler_index(-1);
return *generator;
}
@@ -39,7 +38,7 @@ RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) {
RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) {
HandleScope handle_scope(isolate);
- DCHECK(args.length() == 1);
+ DCHECK(args.length() == 1 || args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0);
JavaScriptFrameIterator stack_iterator(isolate);
@@ -52,28 +51,34 @@ RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) {
DCHECK_LT(0, generator_object->continuation());
// We expect there to be at least two values on the operand stack: the return
- // value of the yield expression, and the argument to this runtime call.
+ // value of the yield expression, and the arguments to this runtime call.
// Neither of those should be saved.
int operands_count = frame->ComputeOperandsCount();
- DCHECK_GE(operands_count, 2);
- operands_count -= 2;
+ DCHECK_GE(operands_count, 1 + args.length());
+ operands_count -= 1 + args.length();
+
+ // Second argument indicates that we need to patch the handler table because
+ // a delegating yield introduced a try-catch statement at expression level,
+ // hence the operand count was off when we statically computed it.
+ // TODO(mstarzinger): This special case disappears with do-expressions.
+ if (args.length() == 2) {
+ CONVERT_SMI_ARG_CHECKED(handler_index, 1);
+ Handle<Code> code(frame->unchecked_code());
+ Handle<HandlerTable> table(HandlerTable::cast(code->handler_table()));
+ int handler_depth = operands_count - TryBlockConstant::kElementCount;
+ table->SetRangeDepth(handler_index, handler_depth);
+ }
if (operands_count == 0) {
// Although it's semantically harmless to call this function with an
// operands_count of zero, it is also unnecessary.
DCHECK_EQ(generator_object->operand_stack(),
isolate->heap()->empty_fixed_array());
- DCHECK_EQ(generator_object->stack_handler_index(), -1);
- // If there are no operands on the stack, there shouldn't be a handler
- // active either.
- DCHECK(!frame->HasHandler());
} else {
- int stack_handler_index = -1;
Handle<FixedArray> operand_stack =
isolate->factory()->NewFixedArray(operands_count);
- frame->SaveOperandStack(*operand_stack, &stack_handler_index);
+ frame->SaveOperandStack(*operand_stack);
generator_object->set_operand_stack(*operand_stack);
- generator_object->set_stack_handler_index(stack_handler_index);
}
return isolate->heap()->undefined_value();
@@ -115,10 +120,8 @@ RUNTIME_FUNCTION(Runtime_ResumeJSGeneratorObject) {
FixedArray* operand_stack = generator_object->operand_stack();
int operands_count = operand_stack->length();
if (operands_count != 0) {
- frame->RestoreOperandStack(operand_stack,
- generator_object->stack_handler_index());
+ frame->RestoreOperandStack(operand_stack);
generator_object->set_operand_stack(isolate->heap()->empty_fixed_array());
- generator_object->set_stack_handler_index(-1);
}
JSGeneratorObject::ResumeMode resume_mode =
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698