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/compiler/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
10 #include "src/compiler/compiler-source-position-table.h" | 10 #include "src/compiler/compiler-source-position-table.h" |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 interpreter::Register first_return = | 1331 interpreter::Register first_return = |
1332 bytecode_iterator().GetRegisterOperand(3); | 1332 bytecode_iterator().GetRegisterOperand(3); |
1333 | 1333 |
1334 // Create node to perform the runtime call. | 1334 // Create node to perform the runtime call. |
1335 const Operator* call = javascript()->CallRuntime(functionId, arg_count); | 1335 const Operator* call = javascript()->CallRuntime(functionId, arg_count); |
1336 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count); | 1336 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count); |
1337 environment()->BindRegistersToProjections(first_return, return_pair, | 1337 environment()->BindRegistersToProjections(first_return, return_pair, |
1338 Environment::kAttachFrameState); | 1338 Environment::kAttachFrameState); |
1339 } | 1339 } |
1340 | 1340 |
| 1341 Node* BytecodeGraphBuilder::ProcessCallNewWithSpreadArguments( |
| 1342 const Operator* op, Node* callee, Node* new_target, |
| 1343 interpreter::Register first_arg, size_t arity) { |
| 1344 Node** all = local_zone()->NewArray<Node*>(arity); |
| 1345 all[0] = callee; |
| 1346 int first_arg_index = first_arg.index(); |
| 1347 for (int i = 1; i < static_cast<int>(arity) - 1; ++i) { |
| 1348 all[i] = environment()->LookupRegister( |
| 1349 interpreter::Register(first_arg_index + i - 1)); |
| 1350 } |
| 1351 all[arity - 1] = new_target; |
| 1352 Node* value = MakeNode(op, static_cast<int>(arity), all, false); |
| 1353 return value; |
| 1354 } |
| 1355 |
1341 void BytecodeGraphBuilder::VisitNewWithSpread() { | 1356 void BytecodeGraphBuilder::VisitNewWithSpread() { |
1342 PrepareEagerCheckpoint(); | 1357 PrepareEagerCheckpoint(); |
1343 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(0); | 1358 interpreter::Register callee_reg = bytecode_iterator().GetRegisterOperand(0); |
1344 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(1); | 1359 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
| 1360 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
| 1361 |
| 1362 Node* new_target = environment()->LookupAccumulator(); |
| 1363 Node* callee = environment()->LookupRegister(callee_reg); |
1345 | 1364 |
1346 const Operator* op = | 1365 const Operator* op = |
1347 javascript()->CallConstructWithSpread(static_cast<int>(arg_count)); | 1366 javascript()->CallConstructWithSpread(static_cast<int>(arg_count) + 2); |
1348 Node* value = ProcessCallRuntimeArguments(op, first_arg, arg_count); | 1367 Node* value = ProcessCallNewWithSpreadArguments(op, callee, new_target, |
| 1368 first_arg, arg_count + 2); |
1349 environment()->BindAccumulator(value, Environment::kAttachFrameState); | 1369 environment()->BindAccumulator(value, Environment::kAttachFrameState); |
1350 } | 1370 } |
1351 | 1371 |
1352 void BytecodeGraphBuilder::VisitInvokeIntrinsic() { | 1372 void BytecodeGraphBuilder::VisitInvokeIntrinsic() { |
1353 PrepareEagerCheckpoint(); | 1373 PrepareEagerCheckpoint(); |
1354 Runtime::FunctionId functionId = bytecode_iterator().GetIntrinsicIdOperand(0); | 1374 Runtime::FunctionId functionId = bytecode_iterator().GetIntrinsicIdOperand(0); |
1355 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); | 1375 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
1356 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1376 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1357 | 1377 |
1358 // Create node to perform the runtime call. Turbofan will take care of the | 1378 // Create node to perform the runtime call. Turbofan will take care of the |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2272 it->source_position().ScriptOffset(), start_position_.InliningId())); | 2292 it->source_position().ScriptOffset(), start_position_.InliningId())); |
2273 it->Advance(); | 2293 it->Advance(); |
2274 } else { | 2294 } else { |
2275 DCHECK_GT(it->code_offset(), offset); | 2295 DCHECK_GT(it->code_offset(), offset); |
2276 } | 2296 } |
2277 } | 2297 } |
2278 | 2298 |
2279 } // namespace compiler | 2299 } // namespace compiler |
2280 } // namespace internal | 2300 } // namespace internal |
2281 } // namespace v8 | 2301 } // namespace v8 |
OLD | NEW |