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