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/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" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) { | 15 RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) { |
16 HandleScope scope(isolate); | 16 HandleScope scope(isolate); |
17 DCHECK(args.length() == 2); | 17 DCHECK(args.length() == 2); |
18 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 18 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
19 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); | 19 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); |
20 CHECK(IsResumableFunction(function->shared()->kind())); | 20 CHECK(IsResumableFunction(function->shared()->kind())); |
21 | 21 |
22 // Underlying function needs to have bytecode available. | 22 // Underlying function needs to have bytecode available. |
23 DCHECK(function->shared()->HasBytecodeArray()); | 23 DCHECK(function->shared()->HasBytecodeArray()); |
24 DCHECK(!function->shared()->HasBaselineCode()); | 24 DCHECK(!function->shared()->HasBaselineCode()); |
25 int size = function->shared()->bytecode_array()->register_count(); | 25 int size = function->shared()->bytecode_array()->register_count(); |
26 Handle<FixedArray> operand_stack = isolate->factory()->NewFixedArray(size); | 26 Handle<FixedArray> register_file = isolate->factory()->NewFixedArray(size); |
27 | 27 |
28 Handle<JSGeneratorObject> generator = | 28 Handle<JSGeneratorObject> generator = |
29 isolate->factory()->NewJSGeneratorObject(function); | 29 isolate->factory()->NewJSGeneratorObject(function); |
30 generator->set_function(*function); | 30 generator->set_function(*function); |
31 generator->set_context(isolate->context()); | 31 generator->set_context(isolate->context()); |
32 generator->set_receiver(*receiver); | 32 generator->set_receiver(*receiver); |
33 generator->set_operand_stack(*operand_stack); | 33 generator->set_register_file(*register_file); |
34 generator->set_continuation(JSGeneratorObject::kGeneratorExecuting); | 34 generator->set_continuation(JSGeneratorObject::kGeneratorExecuting); |
35 return *generator; | 35 return *generator; |
36 } | 36 } |
37 | 37 |
38 RUNTIME_FUNCTION(Runtime_GeneratorClose) { | 38 RUNTIME_FUNCTION(Runtime_GeneratorClose) { |
39 HandleScope scope(isolate); | 39 HandleScope scope(isolate); |
40 DCHECK(args.length() == 1); | 40 DCHECK(args.length() == 1); |
41 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 41 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
42 | 42 |
43 generator->set_continuation(JSGeneratorObject::kGeneratorClosed); | 43 generator->set_continuation(JSGeneratorObject::kGeneratorClosed); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 HandleScope scope(isolate); | 89 HandleScope scope(isolate); |
90 DCHECK(args.length() == 1); | 90 DCHECK(args.length() == 1); |
91 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 91 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
92 | 92 |
93 if (!generator->is_suspended()) return isolate->heap()->undefined_value(); | 93 if (!generator->is_suspended()) return isolate->heap()->undefined_value(); |
94 return Smi::FromInt(generator->source_position()); | 94 return Smi::FromInt(generator->source_position()); |
95 } | 95 } |
96 | 96 |
97 } // namespace internal | 97 } // namespace internal |
98 } // namespace v8 | 98 } // namespace v8 |
OLD | NEW |