OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/interpreter.h" | 5 #include "src/interpreter/interpreter.h" |
6 | 6 |
7 #include <fstream> | 7 #include <fstream> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2169 Node* native_context = __ LoadNativeContext(context); | 2169 Node* native_context = __ LoadNativeContext(context); |
2170 Node* function = __ LoadContextElement(native_context, context_index); | 2170 Node* function = __ LoadContextElement(native_context, context_index); |
2171 | 2171 |
2172 // Call the function. | 2172 // Call the function. |
2173 Node* result = __ CallJS(function, context, first_arg, args_count, | 2173 Node* result = __ CallJS(function, context, first_arg, args_count, |
2174 TailCallMode::kDisallow); | 2174 TailCallMode::kDisallow); |
2175 __ SetAccumulator(result); | 2175 __ SetAccumulator(result); |
2176 __ Dispatch(); | 2176 __ Dispatch(); |
2177 } | 2177 } |
2178 | 2178 |
2179 // NewWithSpread <first_arg> <arg_count> | 2179 // NewWithSpread <constructor> <first_arg> <arg_count> |
2180 // | 2180 // |
2181 // Call the constructor in |first_arg| with the new.target in |first_arg + 1| | 2181 // Call the constructor in |constructor| with the first argument in register |
2182 // for the |arg_count - 2| following arguments. The final argument is always a | 2182 // |first_arg| and |arg_count| arguments in subsequent registers. The final |
2183 // spread. | 2183 // argument is always a spread. The new.target is in the accumulator. |
2184 // | 2184 // |
2185 void Interpreter::DoNewWithSpread(InterpreterAssembler* assembler) { | 2185 void Interpreter::DoNewWithSpread(InterpreterAssembler* assembler) { |
2186 Node* first_arg_reg = __ BytecodeOperandReg(0); | 2186 Node* new_target = __ GetAccumulator(); |
| 2187 Node* constructor_reg = __ BytecodeOperandReg(0); |
| 2188 Node* constructor = __ LoadRegister(constructor_reg); |
| 2189 Node* first_arg_reg = __ BytecodeOperandReg(1); |
2187 Node* first_arg = __ RegisterLocation(first_arg_reg); | 2190 Node* first_arg = __ RegisterLocation(first_arg_reg); |
2188 Node* args_count = __ BytecodeOperandCount(1); | 2191 Node* args_count = __ BytecodeOperandCount(2); |
2189 Node* context = __ GetContext(); | 2192 Node* context = __ GetContext(); |
2190 | 2193 Node* result = __ CallConstructWithSpread(constructor, context, new_target, |
2191 // Call into Runtime function NewWithSpread which does everything. | 2194 first_arg, args_count); |
2192 Node* runtime_function = __ Int32Constant(Runtime::kNewWithSpread); | |
2193 Node* result = | |
2194 __ CallRuntimeN(runtime_function, context, first_arg, args_count); | |
2195 __ SetAccumulator(result); | 2195 __ SetAccumulator(result); |
2196 __ Dispatch(); | 2196 __ Dispatch(); |
2197 } | 2197 } |
2198 | 2198 |
2199 // New <constructor> <first_arg> <arg_count> | 2199 // New <constructor> <first_arg> <arg_count> |
2200 // | 2200 // |
2201 // Call operator new with |constructor| and the first argument in | 2201 // Call operator new with |constructor| and the first argument in |
2202 // register |first_arg| and |arg_count| arguments in subsequent | 2202 // register |first_arg| and |arg_count| arguments in subsequent |
2203 // registers. The new.target is in the accumulator. | 2203 // registers. The new.target is in the accumulator. |
2204 // | 2204 // |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3276 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 3276 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
3277 __ SmiTag(new_state)); | 3277 __ SmiTag(new_state)); |
3278 __ SetAccumulator(old_state); | 3278 __ SetAccumulator(old_state); |
3279 | 3279 |
3280 __ Dispatch(); | 3280 __ Dispatch(); |
3281 } | 3281 } |
3282 | 3282 |
3283 } // namespace interpreter | 3283 } // namespace interpreter |
3284 } // namespace internal | 3284 } // namespace internal |
3285 } // namespace v8 | 3285 } // namespace v8 |
OLD | NEW |