OLD | NEW |
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/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
11 #include "src/objects-inl.h" | 11 #include "src/objects-inl.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) { | 16 RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) { |
17 HandleScope scope(isolate); | 17 HandleScope scope(isolate); |
18 DCHECK(args.length() == 2); | 18 DCHECK(args.length() == 2); |
19 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 19 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
20 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); | 20 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); |
21 CHECK(function->shared()->is_resumable()); | 21 CHECK(function->shared()->is_resumable()); |
22 | 22 |
23 Handle<FixedArray> operand_stack; | 23 Handle<FixedArray> operand_stack; |
24 if (FLAG_ignition && FLAG_ignition_generators) { | 24 if (function->shared()->HasBytecodeArray()) { |
| 25 // New-style generators. |
25 int size = function->shared()->bytecode_array()->register_count(); | 26 int size = function->shared()->bytecode_array()->register_count(); |
26 operand_stack = isolate->factory()->NewFixedArray(size); | 27 operand_stack = isolate->factory()->NewFixedArray(size); |
27 } else { | 28 } else { |
28 DCHECK(!function->shared()->HasBytecodeArray()); | 29 // Old-style generators. |
29 operand_stack = handle(isolate->heap()->empty_fixed_array()); | 30 operand_stack = handle(isolate->heap()->empty_fixed_array()); |
30 } | 31 } |
31 | 32 |
32 Handle<JSGeneratorObject> generator = | 33 Handle<JSGeneratorObject> generator = |
33 isolate->factory()->NewJSGeneratorObject(function); | 34 isolate->factory()->NewJSGeneratorObject(function); |
34 generator->set_function(*function); | 35 generator->set_function(*function); |
35 generator->set_context(isolate->context()); | 36 generator->set_context(isolate->context()); |
36 generator->set_receiver(*receiver); | 37 generator->set_receiver(*receiver); |
37 generator->set_operand_stack(*operand_stack); | 38 generator->set_operand_stack(*operand_stack); |
38 generator->set_continuation(JSGeneratorObject::kGeneratorExecuting); | 39 generator->set_continuation(JSGeneratorObject::kGeneratorExecuting); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 142 } |
142 | 143 |
143 | 144 |
144 RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) { | 145 RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) { |
145 HandleScope scope(isolate); | 146 HandleScope scope(isolate); |
146 DCHECK(args.length() == 1); | 147 DCHECK(args.length() == 1); |
147 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 148 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
148 | 149 |
149 if (!generator->is_suspended()) return isolate->heap()->undefined_value(); | 150 if (!generator->is_suspended()) return isolate->heap()->undefined_value(); |
150 | 151 |
151 if (FLAG_ignition && FLAG_ignition_generators) UNIMPLEMENTED(); | 152 if (generator->function()->shared()->HasBytecodeArray()) UNIMPLEMENTED(); |
152 | 153 |
153 DCHECK(!generator->function()->shared()->HasBytecodeArray()); | |
154 Handle<Code> code(generator->function()->code(), isolate); | 154 Handle<Code> code(generator->function()->code(), isolate); |
155 int offset = generator->continuation(); | 155 int offset = generator->continuation(); |
156 CHECK(0 <= offset && offset < code->instruction_size()); | 156 CHECK(0 <= offset && offset < code->instruction_size()); |
157 return Smi::FromInt(code->SourcePosition(offset)); | 157 return Smi::FromInt(code->SourcePosition(offset)); |
158 } | 158 } |
159 | 159 |
160 } // namespace internal | 160 } // namespace internal |
161 } // namespace v8 | 161 } // namespace v8 |
OLD | NEW |