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/bytecode-branch-analysis.h" | 10 #include "src/compiler/bytecode-branch-analysis.h" |
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 all[1] = environment()->LookupRegister(receiver); | 1245 all[1] = environment()->LookupRegister(receiver); |
1246 int receiver_index = receiver.index(); | 1246 int receiver_index = receiver.index(); |
1247 for (int i = 2; i < static_cast<int>(arity); ++i) { | 1247 for (int i = 2; i < static_cast<int>(arity); ++i) { |
1248 all[i] = environment()->LookupRegister( | 1248 all[i] = environment()->LookupRegister( |
1249 interpreter::Register(receiver_index + i - 1)); | 1249 interpreter::Register(receiver_index + i - 1)); |
1250 } | 1250 } |
1251 Node* value = MakeNode(call_op, static_cast<int>(arity), all, false); | 1251 Node* value = MakeNode(call_op, static_cast<int>(arity), all, false); |
1252 return value; | 1252 return value; |
1253 } | 1253 } |
1254 | 1254 |
1255 void BytecodeGraphBuilder::BuildCall(TailCallMode tail_call_mode) { | 1255 void BytecodeGraphBuilder::BuildCall(TailCallMode tail_call_mode, |
| 1256 ConvertReceiverMode receiver_hint) { |
1256 PrepareEagerCheckpoint(); | 1257 PrepareEagerCheckpoint(); |
1257 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; | 1258 |
1258 Node* callee = | 1259 Node* callee = |
1259 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1260 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1260 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1261 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1261 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1262 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1262 | 1263 |
1263 // Slot index of 0 is used indicate no feedback slot is available. Assert | 1264 // Slot index of 0 is used indicate no feedback slot is available. Assert |
1264 // the assumption that slot index 0 is never a valid feedback slot. | 1265 // the assumption that slot index 0 is never a valid feedback slot. |
1265 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); | 1266 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
1266 int const slot_id = bytecode_iterator().GetIndexOperand(3); | 1267 int const slot_id = bytecode_iterator().GetIndexOperand(3); |
1267 VectorSlotPair feedback = CreateVectorSlotPair(slot_id); | 1268 VectorSlotPair feedback = CreateVectorSlotPair(slot_id); |
1268 | 1269 |
1269 float const frequency = ComputeCallFrequency(slot_id); | 1270 float const frequency = ComputeCallFrequency(slot_id); |
1270 const Operator* call = javascript()->CallFunction( | 1271 const Operator* call = javascript()->CallFunction( |
1271 arg_count + 1, frequency, feedback, receiver_hint, tail_call_mode); | 1272 arg_count + 1, frequency, feedback, receiver_hint, tail_call_mode); |
1272 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 1273 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
1273 environment()->BindAccumulator(value, Environment::kAttachFrameState); | 1274 environment()->BindAccumulator(value, Environment::kAttachFrameState); |
1274 } | 1275 } |
1275 | 1276 |
1276 void BytecodeGraphBuilder::VisitCall() { BuildCall(TailCallMode::kDisallow); } | 1277 void BytecodeGraphBuilder::VisitCall() { |
| 1278 BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kAny); |
| 1279 } |
| 1280 |
| 1281 void BytecodeGraphBuilder::VisitCallProperty() { |
| 1282 BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kNotNullOrUndefined); |
| 1283 } |
1277 | 1284 |
1278 void BytecodeGraphBuilder::VisitTailCall() { | 1285 void BytecodeGraphBuilder::VisitTailCall() { |
1279 TailCallMode tail_call_mode = | 1286 TailCallMode tail_call_mode = |
1280 bytecode_array_->GetIsolate()->is_tail_call_elimination_enabled() | 1287 bytecode_array_->GetIsolate()->is_tail_call_elimination_enabled() |
1281 ? TailCallMode::kAllow | 1288 ? TailCallMode::kAllow |
1282 : TailCallMode::kDisallow; | 1289 : TailCallMode::kDisallow; |
1283 BuildCall(tail_call_mode); | 1290 BuildCall(tail_call_mode, ConvertReceiverMode::kAny); |
1284 } | 1291 } |
1285 | 1292 |
1286 void BytecodeGraphBuilder::VisitCallJSRuntime() { | 1293 void BytecodeGraphBuilder::VisitCallJSRuntime() { |
1287 PrepareEagerCheckpoint(); | 1294 PrepareEagerCheckpoint(); |
1288 Node* callee = | 1295 Node* callee = |
1289 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); | 1296 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); |
1290 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1297 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1291 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1298 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1292 | 1299 |
1293 // Create node to perform the JS runtime call. | 1300 // Create node to perform the JS runtime call. |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2198 source_positions_->set_current_position(it->source_position()); | 2205 source_positions_->set_current_position(it->source_position()); |
2199 it->Advance(); | 2206 it->Advance(); |
2200 } else { | 2207 } else { |
2201 DCHECK_GT(it->code_offset(), offset); | 2208 DCHECK_GT(it->code_offset(), offset); |
2202 } | 2209 } |
2203 } | 2210 } |
2204 | 2211 |
2205 } // namespace compiler | 2212 } // namespace compiler |
2206 } // namespace internal | 2213 } // namespace internal |
2207 } // namespace v8 | 2214 } // namespace v8 |
OLD | NEW |