Chromium Code Reviews| 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() == 0); | 17 DCHECK(args.length() == 2); |
|
Benedikt Meurer
2016/04/12 12:57:03
Nit: DCHECK_EQ(2, args.length())
| |
| 18 | 18 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 19 JavaScriptFrameIterator it(isolate); | 19 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); |
| 20 JavaScriptFrame* frame = it.frame(); | |
| 21 Handle<JSFunction> function(frame->function()); | |
| 22 RUNTIME_ASSERT(function->shared()->is_generator()); | 20 RUNTIME_ASSERT(function->shared()->is_generator()); |
| 23 | 21 |
| 24 Handle<JSGeneratorObject> generator; | 22 Handle<JSGeneratorObject> generator = |
| 25 DCHECK(!frame->IsConstructor()); | 23 isolate->factory()->NewJSGeneratorObject(function); |
| 26 generator = isolate->factory()->NewJSGeneratorObject(function); | |
| 27 generator->set_function(*function); | 24 generator->set_function(*function); |
| 28 generator->set_context(Context::cast(frame->context())); | 25 generator->set_context(isolate->context()); |
| 29 generator->set_receiver(frame->receiver()); | 26 generator->set_receiver(*receiver); |
| 30 generator->set_continuation(0); | |
| 31 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); | 27 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); |
| 32 | |
| 33 return *generator; | 28 return *generator; |
| 34 } | 29 } |
| 35 | 30 |
| 36 | 31 |
| 37 RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) { | 32 RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) { |
| 38 HandleScope handle_scope(isolate); | 33 HandleScope handle_scope(isolate); |
| 39 DCHECK(args.length() == 1); | 34 DCHECK(args.length() == 1); |
| 40 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); | 35 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); |
| 41 | 36 |
| 42 JavaScriptFrameIterator stack_iterator(isolate); | 37 JavaScriptFrameIterator stack_iterator(isolate); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 int offset = generator->continuation(); | 128 int offset = generator->continuation(); |
| 134 RUNTIME_ASSERT(0 <= offset && offset < code->instruction_size()); | 129 RUNTIME_ASSERT(0 <= offset && offset < code->instruction_size()); |
| 135 return Smi::FromInt(code->SourcePosition(offset)); | 130 return Smi::FromInt(code->SourcePosition(offset)); |
| 136 } | 131 } |
| 137 | 132 |
| 138 return isolate->heap()->undefined_value(); | 133 return isolate->heap()->undefined_value(); |
| 139 } | 134 } |
| 140 | 135 |
| 141 } // namespace internal | 136 } // namespace internal |
| 142 } // namespace v8 | 137 } // namespace v8 |
| OLD | NEW |