| 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" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } else { | 70 } else { |
| 71 Handle<FixedArray> operand_stack = | 71 Handle<FixedArray> operand_stack = |
| 72 isolate->factory()->NewFixedArray(operands_count); | 72 isolate->factory()->NewFixedArray(operands_count); |
| 73 frame->SaveOperandStack(*operand_stack); | 73 frame->SaveOperandStack(*operand_stack); |
| 74 generator_object->set_operand_stack(*operand_stack); | 74 generator_object->set_operand_stack(*operand_stack); |
| 75 } | 75 } |
| 76 | 76 |
| 77 return isolate->heap()->undefined_value(); | 77 return isolate->heap()->undefined_value(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 | |
| 81 RUNTIME_FUNCTION(Runtime_GeneratorClose) { | 80 RUNTIME_FUNCTION(Runtime_GeneratorClose) { |
| 82 HandleScope scope(isolate); | 81 HandleScope scope(isolate); |
| 83 DCHECK(args.length() == 1); | 82 DCHECK(args.length() == 1); |
| 84 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 83 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
| 85 | 84 |
| 86 generator->set_continuation(JSGeneratorObject::kGeneratorClosed); | 85 generator->set_continuation(JSGeneratorObject::kGeneratorClosed); |
| 87 | 86 |
| 88 return isolate->heap()->undefined_value(); | 87 return isolate->heap()->undefined_value(); |
| 89 } | 88 } |
| 90 | 89 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 111 | 110 |
| 112 // Returns input of generator activation. | 111 // Returns input of generator activation. |
| 113 RUNTIME_FUNCTION(Runtime_GeneratorGetInput) { | 112 RUNTIME_FUNCTION(Runtime_GeneratorGetInput) { |
| 114 HandleScope scope(isolate); | 113 HandleScope scope(isolate); |
| 115 DCHECK(args.length() == 1); | 114 DCHECK(args.length() == 1); |
| 116 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 115 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
| 117 | 116 |
| 118 return generator->input(); | 117 return generator->input(); |
| 119 } | 118 } |
| 120 | 119 |
| 121 | |
| 122 // Returns resume mode of generator activation. | 120 // Returns resume mode of generator activation. |
| 123 RUNTIME_FUNCTION(Runtime_GeneratorGetResumeMode) { | 121 RUNTIME_FUNCTION(Runtime_GeneratorGetResumeMode) { |
| 124 HandleScope scope(isolate); | 122 HandleScope scope(isolate); |
| 125 DCHECK(args.length() == 1); | 123 DCHECK(args.length() == 1); |
| 126 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 124 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
| 127 | 125 |
| 128 return Smi::FromInt(generator->resume_mode()); | 126 return Smi::FromInt(generator->resume_mode()); |
| 129 } | 127 } |
| 130 | 128 |
| 131 | |
| 132 // Returns generator continuation as a PC offset, or the magic -1 or 0 values. | 129 // Returns generator continuation as a PC offset, or the magic -1 or 0 values. |
| 133 RUNTIME_FUNCTION(Runtime_GeneratorGetContinuation) { | 130 RUNTIME_FUNCTION(Runtime_GeneratorGetContinuation) { |
| 134 HandleScope scope(isolate); | 131 HandleScope scope(isolate); |
| 135 DCHECK(args.length() == 1); | 132 DCHECK(args.length() == 1); |
| 136 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 133 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
| 137 | 134 |
| 138 return Smi::FromInt(generator->continuation()); | 135 return Smi::FromInt(generator->continuation()); |
| 139 } | 136 } |
| 140 | 137 |
| 141 | 138 |
| 142 RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) { | 139 RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) { |
| 143 HandleScope scope(isolate); | 140 HandleScope scope(isolate); |
| 144 DCHECK(args.length() == 1); | 141 DCHECK(args.length() == 1); |
| 145 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 142 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
| 146 | 143 |
| 147 if (generator->is_suspended()) { | 144 if (generator->is_suspended()) { |
| 148 Handle<Code> code(generator->function()->code(), isolate); | 145 Handle<Code> code(generator->function()->code(), isolate); |
| 149 int offset = generator->continuation(); | 146 int offset = generator->continuation(); |
| 150 RUNTIME_ASSERT(0 <= offset && offset < code->instruction_size()); | 147 RUNTIME_ASSERT(0 <= offset && offset < code->instruction_size()); |
| 151 return Smi::FromInt(code->SourcePosition(offset)); | 148 return Smi::FromInt(code->SourcePosition(offset)); |
| 152 } | 149 } |
| 153 | 150 |
| 154 return isolate->heap()->undefined_value(); | 151 return isolate->heap()->undefined_value(); |
| 155 } | 152 } |
| 156 | 153 |
| 157 } // namespace internal | 154 } // namespace internal |
| 158 } // namespace v8 | 155 } // namespace v8 |
| OLD | NEW |