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 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1257 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1258 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1258 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1259 | 1259 |
1260 // Slot index of 0 is used indicate no feedback slot is available. Assert | 1260 // Slot index of 0 is used indicate no feedback slot is available. Assert |
1261 // the assumption that slot index 0 is never a valid feedback slot. | 1261 // the assumption that slot index 0 is never a valid feedback slot. |
1262 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); | 1262 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
1263 int const slot_id = bytecode_iterator().GetIndexOperand(3); | 1263 int const slot_id = bytecode_iterator().GetIndexOperand(3); |
1264 VectorSlotPair feedback = CreateVectorSlotPair(slot_id); | 1264 VectorSlotPair feedback = CreateVectorSlotPair(slot_id); |
1265 | 1265 |
1266 float const frequency = ComputeCallFrequency(slot_id); | 1266 float const frequency = ComputeCallFrequency(slot_id); |
1267 const Operator* call = javascript()->CallFunction( | 1267 const Operator* call = javascript()->Call(arg_count + 1, frequency, feedback, |
1268 arg_count + 1, frequency, feedback, receiver_hint, tail_call_mode); | 1268 receiver_hint, tail_call_mode); |
1269 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 1269 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
1270 environment()->BindAccumulator(value, Environment::kAttachFrameState); | 1270 environment()->BindAccumulator(value, Environment::kAttachFrameState); |
1271 } | 1271 } |
1272 | 1272 |
1273 void BytecodeGraphBuilder::VisitCall() { | 1273 void BytecodeGraphBuilder::VisitCall() { |
1274 BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kAny); | 1274 BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kAny); |
1275 } | 1275 } |
1276 | 1276 |
1277 void BytecodeGraphBuilder::VisitCallWithSpread() { | 1277 void BytecodeGraphBuilder::VisitCallWithSpread() { |
1278 PrepareEagerCheckpoint(); | 1278 PrepareEagerCheckpoint(); |
1279 Node* callee = | 1279 Node* callee = |
1280 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1280 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1281 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1281 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1282 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1282 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1283 const Operator* call = | 1283 const Operator* call = |
1284 javascript()->CallFunctionWithSpread(static_cast<int>(arg_count + 1)); | 1284 javascript()->CallWithSpread(static_cast<int>(arg_count + 1)); |
1285 | 1285 |
1286 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 1286 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
1287 environment()->BindAccumulator(value, Environment::kAttachFrameState); | 1287 environment()->BindAccumulator(value, Environment::kAttachFrameState); |
1288 } | 1288 } |
1289 | 1289 |
1290 void BytecodeGraphBuilder::VisitCallProperty() { | 1290 void BytecodeGraphBuilder::VisitCallProperty() { |
1291 BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kNotNullOrUndefined); | 1291 BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kNotNullOrUndefined); |
1292 } | 1292 } |
1293 | 1293 |
1294 void BytecodeGraphBuilder::VisitTailCall() { | 1294 void BytecodeGraphBuilder::VisitTailCall() { |
1295 TailCallMode tail_call_mode = | 1295 TailCallMode tail_call_mode = |
1296 bytecode_array_->GetIsolate()->is_tail_call_elimination_enabled() | 1296 bytecode_array_->GetIsolate()->is_tail_call_elimination_enabled() |
1297 ? TailCallMode::kAllow | 1297 ? TailCallMode::kAllow |
1298 : TailCallMode::kDisallow; | 1298 : TailCallMode::kDisallow; |
1299 BuildCall(tail_call_mode, ConvertReceiverMode::kAny); | 1299 BuildCall(tail_call_mode, ConvertReceiverMode::kAny); |
1300 } | 1300 } |
1301 | 1301 |
1302 void BytecodeGraphBuilder::VisitCallJSRuntime() { | 1302 void BytecodeGraphBuilder::VisitCallJSRuntime() { |
1303 PrepareEagerCheckpoint(); | 1303 PrepareEagerCheckpoint(); |
1304 Node* callee = | 1304 Node* callee = |
1305 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); | 1305 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); |
1306 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1306 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1307 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1307 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1308 | 1308 |
1309 // Create node to perform the JS runtime call. | 1309 // Create node to perform the JS runtime call. |
1310 const Operator* call = javascript()->CallFunction(arg_count + 1); | 1310 const Operator* call = javascript()->Call(arg_count + 1); |
1311 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 1311 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
1312 environment()->BindAccumulator(value, Environment::kAttachFrameState); | 1312 environment()->BindAccumulator(value, Environment::kAttachFrameState); |
1313 } | 1313 } |
1314 | 1314 |
1315 Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments( | 1315 Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments( |
1316 const Operator* call_runtime_op, interpreter::Register first_arg, | 1316 const Operator* call_runtime_op, interpreter::Register first_arg, |
1317 size_t arity) { | 1317 size_t arity) { |
1318 Node** all = local_zone()->NewArray<Node*>(arity); | 1318 Node** all = local_zone()->NewArray<Node*>(arity); |
1319 int first_arg_index = first_arg.index(); | 1319 int first_arg_index = first_arg.index(); |
1320 for (int i = 0; i < static_cast<int>(arity); ++i) { | 1320 for (int i = 0; i < static_cast<int>(arity); ++i) { |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2301 it->source_position().ScriptOffset(), start_position_.InliningId())); | 2301 it->source_position().ScriptOffset(), start_position_.InliningId())); |
2302 it->Advance(); | 2302 it->Advance(); |
2303 } else { | 2303 } else { |
2304 DCHECK_GT(it->code_offset(), offset); | 2304 DCHECK_GT(it->code_offset(), offset); |
2305 } | 2305 } |
2306 } | 2306 } |
2307 | 2307 |
2308 } // namespace compiler | 2308 } // namespace compiler |
2309 } // namespace internal | 2309 } // namespace internal |
2310 } // namespace v8 | 2310 } // namespace v8 |
OLD | NEW |