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

Side by Side Diff: src/runtime/runtime-generator.cc

Issue 1856683002: Fix resuming generator marked for optimization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-513471.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 25 matching lines...) Expand all
36 36
37 RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) { 37 RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) {
38 HandleScope handle_scope(isolate); 38 HandleScope handle_scope(isolate);
39 DCHECK(args.length() == 1); 39 DCHECK(args.length() == 1);
40 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); 40 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0);
41 41
42 JavaScriptFrameIterator stack_iterator(isolate); 42 JavaScriptFrameIterator stack_iterator(isolate);
43 JavaScriptFrame* frame = stack_iterator.frame(); 43 JavaScriptFrame* frame = stack_iterator.frame();
44 RUNTIME_ASSERT(frame->function()->shared()->is_generator()); 44 RUNTIME_ASSERT(frame->function()->shared()->is_generator());
45 DCHECK_EQ(frame->function(), generator_object->function()); 45 DCHECK_EQ(frame->function(), generator_object->function());
46 DCHECK(frame->function()->shared()->is_compiled());
47 DCHECK(!frame->function()->IsOptimized());
46 48
47 // The caller should have saved the context and continuation already. 49 // The caller should have saved the context and continuation already.
48 DCHECK_EQ(generator_object->context(), Context::cast(frame->context())); 50 DCHECK_EQ(generator_object->context(), Context::cast(frame->context()));
49 DCHECK_LT(0, generator_object->continuation()); 51 DCHECK_LT(0, generator_object->continuation());
50 52
51 // We expect there to be at least two values on the operand stack: the return 53 // We expect there to be at least two values on the operand stack: the return
52 // value of the yield expression, and the arguments to this runtime call. 54 // value of the yield expression, and the arguments to this runtime call.
53 // Neither of those should be saved. 55 // Neither of those should be saved.
54 int operands_count = frame->ComputeOperandsCount(); 56 int operands_count = frame->ComputeOperandsCount();
55 DCHECK_GE(operands_count, 1 + args.length()); 57 DCHECK_GE(operands_count, 1 + args.length());
(...skipping 25 matching lines...) Expand all
81 RUNTIME_FUNCTION(Runtime_ResumeJSGeneratorObject) { 83 RUNTIME_FUNCTION(Runtime_ResumeJSGeneratorObject) {
82 SealHandleScope shs(isolate); 84 SealHandleScope shs(isolate);
83 DCHECK(args.length() == 3); 85 DCHECK(args.length() == 3);
84 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); 86 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0);
85 CONVERT_ARG_CHECKED(Object, value, 1); 87 CONVERT_ARG_CHECKED(Object, value, 1);
86 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); 88 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2);
87 JavaScriptFrameIterator stack_iterator(isolate); 89 JavaScriptFrameIterator stack_iterator(isolate);
88 JavaScriptFrame* frame = stack_iterator.frame(); 90 JavaScriptFrame* frame = stack_iterator.frame();
89 91
90 DCHECK_EQ(frame->function(), generator_object->function()); 92 DCHECK_EQ(frame->function(), generator_object->function());
91 DCHECK(frame->function()->is_compiled()); 93 DCHECK(frame->function()->shared()->is_compiled());
94 DCHECK(!frame->function()->IsOptimized());
92 95
93 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0); 96 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
94 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0); 97 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0);
95 98
96 Address pc = generator_object->function()->code()->instruction_start(); 99 Code* code = generator_object->function()->shared()->code();
97 int offset = generator_object->continuation(); 100 int offset = generator_object->continuation();
98 DCHECK(offset > 0); 101 DCHECK_GT(offset, 0);
99 frame->set_pc(pc + offset); 102 frame->set_pc(code->instruction_start() + offset);
100 if (FLAG_enable_embedded_constant_pool) { 103 if (FLAG_enable_embedded_constant_pool) {
101 frame->set_constant_pool( 104 frame->set_constant_pool(code->constant_pool());
102 generator_object->function()->code()->constant_pool());
103 } 105 }
104 generator_object->set_continuation(JSGeneratorObject::kGeneratorExecuting); 106 generator_object->set_continuation(JSGeneratorObject::kGeneratorExecuting);
105 107
106 FixedArray* operand_stack = generator_object->operand_stack(); 108 FixedArray* operand_stack = generator_object->operand_stack();
107 int operands_count = operand_stack->length(); 109 int operands_count = operand_stack->length();
108 if (operands_count != 0) { 110 if (operands_count != 0) {
109 frame->RestoreOperandStack(operand_stack); 111 frame->RestoreOperandStack(operand_stack);
110 generator_object->set_operand_stack(isolate->heap()->empty_fixed_array()); 112 generator_object->set_operand_stack(isolate->heap()->empty_fixed_array());
111 } 113 }
112 114
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return nullptr; 218 return nullptr;
217 } 219 }
218 220
219 RUNTIME_FUNCTION(Runtime_GeneratorThrow) { 221 RUNTIME_FUNCTION(Runtime_GeneratorThrow) {
220 UNREACHABLE(); 222 UNREACHABLE();
221 return nullptr; 223 return nullptr;
222 } 224 }
223 225
224 } // namespace internal 226 } // namespace internal
225 } // namespace v8 227 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-513471.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698