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 // CallWithSpread <first_arg> <arg_count> | 2179 // CallWithSpread <callable> <first_arg> <arg_count> |
2180 // | 2180 // |
2181 // Call a JSfunction or Callable in |first_arg| with the receiver in | 2181 // Call a JSfunction or Callable in |callable| with the receiver in |
2182 // |first_arg + 1| and |arg_count - 2| arguments in subsequent registers. The | 2182 // |first_arg| and |arg_count - 1| arguments in subsequent registers. The |
2183 // final argument is always a spread. | 2183 // final argument is always a spread. |
2184 // | 2184 // |
2185 void Interpreter::DoCallWithSpread(InterpreterAssembler* assembler) { | 2185 void Interpreter::DoCallWithSpread(InterpreterAssembler* assembler) { |
2186 Node* first_arg_reg = __ BytecodeOperandReg(0); | 2186 Node* callable_reg = __ BytecodeOperandReg(0); |
2187 Node* first_arg = __ RegisterLocation(first_arg_reg); | 2187 Node* callable = __ LoadRegister(callable_reg); |
2188 Node* args_count = __ BytecodeOperandCount(1); | 2188 Node* receiver_reg = __ BytecodeOperandReg(1); |
| 2189 Node* receiver_arg = __ RegisterLocation(receiver_reg); |
| 2190 Node* receiver_args_count = __ BytecodeOperandCount(2); |
| 2191 Node* receiver_count = __ Int32Constant(1); |
| 2192 Node* args_count = __ Int32Sub(receiver_args_count, receiver_count); |
2189 Node* context = __ GetContext(); | 2193 Node* context = __ GetContext(); |
2190 | 2194 |
2191 // Call into Runtime function CallWithSpread which does everything. | 2195 // Call into Runtime function CallWithSpread which does everything. |
2192 Node* runtime_function = __ Int32Constant(Runtime::kCallWithSpread); | |
2193 Node* result = | 2196 Node* result = |
2194 __ CallRuntimeN(runtime_function, context, first_arg, args_count); | 2197 __ CallJSWithSpread(callable, context, receiver_arg, args_count); |
2195 __ SetAccumulator(result); | 2198 __ SetAccumulator(result); |
2196 __ Dispatch(); | 2199 __ Dispatch(); |
2197 } | 2200 } |
2198 | 2201 |
2199 // NewWithSpread <first_arg> <arg_count> | 2202 // NewWithSpread <first_arg> <arg_count> |
2200 // | 2203 // |
2201 // Call the constructor in |constructor| with the first argument in register | 2204 // Call the constructor in |constructor| with the first argument in register |
2202 // |first_arg| and |arg_count| arguments in subsequent registers. The final | 2205 // |first_arg| and |arg_count| arguments in subsequent registers. The final |
2203 // argument is always a spread. The new.target is in the accumulator. | 2206 // argument is always a spread. The new.target is in the accumulator. |
2204 // | 2207 // |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3296 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 3299 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
3297 __ SmiTag(new_state)); | 3300 __ SmiTag(new_state)); |
3298 __ SetAccumulator(old_state); | 3301 __ SetAccumulator(old_state); |
3299 | 3302 |
3300 __ Dispatch(); | 3303 __ Dispatch(); |
3301 } | 3304 } |
3302 | 3305 |
3303 } // namespace interpreter | 3306 } // namespace interpreter |
3304 } // namespace internal | 3307 } // namespace internal |
3305 } // namespace v8 | 3308 } // namespace v8 |
OLD | NEW |