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 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 interpreter::Register first_return = | 1325 interpreter::Register first_return = |
1326 bytecode_iterator().GetRegisterOperand(3); | 1326 bytecode_iterator().GetRegisterOperand(3); |
1327 | 1327 |
1328 // Create node to perform the runtime call. | 1328 // Create node to perform the runtime call. |
1329 const Operator* call = javascript()->CallRuntime(functionId, arg_count); | 1329 const Operator* call = javascript()->CallRuntime(functionId, arg_count); |
1330 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count); | 1330 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count); |
1331 environment()->BindRegistersToProjections(first_return, return_pair, | 1331 environment()->BindRegistersToProjections(first_return, return_pair, |
1332 Environment::kAttachFrameState); | 1332 Environment::kAttachFrameState); |
1333 } | 1333 } |
1334 | 1334 |
| 1335 Node* BytecodeGraphBuilder::ProcessCallNewWithSpreadArguments( |
| 1336 const Operator* op, Node* callee, Node* new_target, |
| 1337 interpreter::Register first_arg, size_t arity) { |
| 1338 Node** all = local_zone()->NewArray<Node*>(arity); |
| 1339 all[0] = callee; |
| 1340 int first_arg_index = first_arg.index(); |
| 1341 for (int i = 1; i < static_cast<int>(arity) - 1; ++i) { |
| 1342 all[i] = environment()->LookupRegister( |
| 1343 interpreter::Register(first_arg_index + i - 1)); |
| 1344 } |
| 1345 all[arity - 1] = new_target; |
| 1346 Node* value = MakeNode(op, static_cast<int>(arity), all, false); |
| 1347 return value; |
| 1348 } |
| 1349 |
1335 void BytecodeGraphBuilder::VisitNewWithSpread() { | 1350 void BytecodeGraphBuilder::VisitNewWithSpread() { |
1336 PrepareEagerCheckpoint(); | 1351 PrepareEagerCheckpoint(); |
1337 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(0); | 1352 interpreter::Register callee_reg = bytecode_iterator().GetRegisterOperand(0); |
1338 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(1); | 1353 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
| 1354 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
| 1355 |
| 1356 Node* new_target = environment()->LookupAccumulator(); |
| 1357 Node* callee = environment()->LookupRegister(callee_reg); |
1339 | 1358 |
1340 const Operator* op = | 1359 const Operator* op = |
1341 javascript()->CallConstructWithSpread(static_cast<int>(arg_count)); | 1360 javascript()->CallConstructWithSpread(static_cast<int>(arg_count) + 2); |
1342 Node* value = ProcessCallRuntimeArguments(op, first_arg, arg_count); | 1361 Node* value = ProcessCallNewWithSpreadArguments(op, callee, new_target, |
| 1362 first_arg, arg_count + 2); |
1343 environment()->BindAccumulator(value, Environment::kAttachFrameState); | 1363 environment()->BindAccumulator(value, Environment::kAttachFrameState); |
1344 } | 1364 } |
1345 | 1365 |
1346 void BytecodeGraphBuilder::VisitInvokeIntrinsic() { | 1366 void BytecodeGraphBuilder::VisitInvokeIntrinsic() { |
1347 PrepareEagerCheckpoint(); | 1367 PrepareEagerCheckpoint(); |
1348 Runtime::FunctionId functionId = bytecode_iterator().GetIntrinsicIdOperand(0); | 1368 Runtime::FunctionId functionId = bytecode_iterator().GetIntrinsicIdOperand(0); |
1349 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); | 1369 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
1350 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1370 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1351 | 1371 |
1352 // Create node to perform the runtime call. Turbofan will take care of the | 1372 // Create node to perform the runtime call. Turbofan will take care of the |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2267 it->source_position().ScriptOffset(), start_position_.InliningId())); | 2287 it->source_position().ScriptOffset(), start_position_.InliningId())); |
2268 it->Advance(); | 2288 it->Advance(); |
2269 } else { | 2289 } else { |
2270 DCHECK_GT(it->code_offset(), offset); | 2290 DCHECK_GT(it->code_offset(), offset); |
2271 } | 2291 } |
2272 } | 2292 } |
2273 | 2293 |
2274 } // namespace compiler | 2294 } // namespace compiler |
2275 } // namespace internal | 2295 } // namespace internal |
2276 } // namespace v8 | 2296 } // namespace v8 |
OLD | NEW |