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 (function->shared()->HasBytecodeArray()) { | 24 if (function->shared()->HasBytecodeArray()) { |
25 // New-style generators. | 25 // New-style generators. |
| 26 DCHECK(!function->shared()->HasBaselineCode()); |
26 int size = function->shared()->bytecode_array()->register_count(); | 27 int size = function->shared()->bytecode_array()->register_count(); |
27 operand_stack = isolate->factory()->NewFixedArray(size); | 28 operand_stack = isolate->factory()->NewFixedArray(size); |
28 } else { | 29 } else { |
29 // Old-style generators. | 30 // Old-style generators. |
| 31 DCHECK(function->shared()->HasBaselineCode()); |
30 operand_stack = isolate->factory()->empty_fixed_array(); | 32 operand_stack = isolate->factory()->empty_fixed_array(); |
31 } | 33 } |
32 | 34 |
33 Handle<JSGeneratorObject> generator = | 35 Handle<JSGeneratorObject> generator = |
34 isolate->factory()->NewJSGeneratorObject(function); | 36 isolate->factory()->NewJSGeneratorObject(function); |
35 generator->set_function(*function); | 37 generator->set_function(*function); |
36 generator->set_context(isolate->context()); | 38 generator->set_context(isolate->context()); |
37 generator->set_receiver(*receiver); | 39 generator->set_receiver(*receiver); |
38 generator->set_operand_stack(*operand_stack); | 40 generator->set_operand_stack(*operand_stack); |
39 generator->set_continuation(JSGeneratorObject::kGeneratorExecuting); | 41 generator->set_continuation(JSGeneratorObject::kGeneratorExecuting); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 HandleScope scope(isolate); | 136 HandleScope scope(isolate); |
135 DCHECK(args.length() == 1); | 137 DCHECK(args.length() == 1); |
136 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 138 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
137 | 139 |
138 if (!generator->is_suspended()) return isolate->heap()->undefined_value(); | 140 if (!generator->is_suspended()) return isolate->heap()->undefined_value(); |
139 return Smi::FromInt(generator->source_position()); | 141 return Smi::FromInt(generator->source_position()); |
140 } | 142 } |
141 | 143 |
142 } // namespace internal | 144 } // namespace internal |
143 } // namespace v8 | 145 } // namespace v8 |
OLD | NEW |