| 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/compiler/bytecode-branch-analysis.h" | 7 #include "src/compiler/bytecode-branch-analysis.h" |
| 8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
| 9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
| 10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 Node* BytecodeGraphBuilder::BuildLoadNativeContextField(int index) { | 495 Node* BytecodeGraphBuilder::BuildLoadNativeContextField(int index) { |
| 496 const Operator* op = | 496 const Operator* op = |
| 497 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true); | 497 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true); |
| 498 Node* native_context = NewNode(op, environment()->Context()); | 498 Node* native_context = NewNode(op, environment()->Context()); |
| 499 return NewNode(javascript()->LoadContext(0, index, true), native_context); | 499 return NewNode(javascript()->LoadContext(0, index, true), native_context); |
| 500 } | 500 } |
| 501 | 501 |
| 502 | 502 |
| 503 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { | 503 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { |
| 504 FeedbackVectorSlot slot = feedback_vector()->ToSlot(slot_id); | 504 FeedbackVectorSlot slot; |
| 505 if (slot_id >= TypeFeedbackVector::kReservedIndexCount) { |
| 506 slot = feedback_vector()->ToSlot(slot_id); |
| 507 } |
| 505 return VectorSlotPair(feedback_vector(), slot); | 508 return VectorSlotPair(feedback_vector(), slot); |
| 506 } | 509 } |
| 507 | 510 |
| 508 bool BytecodeGraphBuilder::CreateGraph() { | 511 bool BytecodeGraphBuilder::CreateGraph() { |
| 509 // Set up the basic structure of the graph. Outputs for {Start} are | 512 // Set up the basic structure of the graph. Outputs for {Start} are |
| 510 // the formal parameters (including the receiver) plus context and | 513 // the formal parameters (including the receiver) plus context and |
| 511 // closure. | 514 // closure. |
| 512 | 515 |
| 513 // Set up the basic structure of the graph. Outputs for {Start} are the formal | 516 // Set up the basic structure of the graph. Outputs for {Start} are the formal |
| 514 // parameters (including the receiver) plus new target, number of arguments, | 517 // parameters (including the receiver) plus new target, number of arguments, |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 all[1] = environment()->LookupRegister(receiver); | 985 all[1] = environment()->LookupRegister(receiver); |
| 983 int receiver_index = receiver.index(); | 986 int receiver_index = receiver.index(); |
| 984 for (int i = 2; i < static_cast<int>(arity); ++i) { | 987 for (int i = 2; i < static_cast<int>(arity); ++i) { |
| 985 all[i] = environment()->LookupRegister( | 988 all[i] = environment()->LookupRegister( |
| 986 interpreter::Register(receiver_index + i - 1)); | 989 interpreter::Register(receiver_index + i - 1)); |
| 987 } | 990 } |
| 988 Node* value = MakeNode(call_op, static_cast<int>(arity), all, false); | 991 Node* value = MakeNode(call_op, static_cast<int>(arity), all, false); |
| 989 return value; | 992 return value; |
| 990 } | 993 } |
| 991 | 994 |
| 992 void BytecodeGraphBuilder::BuildCallWithFeedbackSlot( | 995 void BytecodeGraphBuilder::BuildCall(TailCallMode tail_call_mode) { |
| 993 TailCallMode tail_call_mode) { | |
| 994 FrameStateBeforeAndAfter states(this); | 996 FrameStateBeforeAndAfter states(this); |
| 995 // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver | 997 // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver |
| 996 // register has been loaded with null / undefined explicitly or we are sure it | 998 // register has been loaded with null / undefined explicitly or we are sure it |
| 997 // is not null / undefined. | 999 // is not null / undefined. |
| 998 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; | 1000 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; |
| 999 Node* callee = | 1001 Node* callee = |
| 1000 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1002 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 1001 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | 1003 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
| 1002 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1004 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
| 1003 int slot_id = bytecode_iterator().GetIndexOperand(3); | 1005 VectorSlotPair feedback = |
| 1004 VectorSlotPair feedback = CreateVectorSlotPair(slot_id); | 1006 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); |
| 1005 | 1007 |
| 1006 const Operator* call = javascript()->CallFunction( | 1008 const Operator* call = javascript()->CallFunction( |
| 1007 arg_count + 1, feedback, receiver_hint, tail_call_mode); | 1009 arg_count + 1, feedback, receiver_hint, tail_call_mode); |
| 1008 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | 1010 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); |
| 1009 environment()->BindAccumulator(value, &states); | 1011 environment()->BindAccumulator(value, &states); |
| 1010 } | 1012 } |
| 1011 | |
| 1012 void BytecodeGraphBuilder::VisitCallIC() { | |
| 1013 BuildCallWithFeedbackSlot(TailCallMode::kDisallow); | |
| 1014 } | |
| 1015 | |
| 1016 void BytecodeGraphBuilder::VisitCallICWide() { | |
| 1017 BuildCallWithFeedbackSlot(TailCallMode::kDisallow); | |
| 1018 } | |
| 1019 | |
| 1020 void BytecodeGraphBuilder::VisitTailCallIC() { | |
| 1021 BuildCallWithFeedbackSlot(TailCallMode::kAllow); | |
| 1022 } | |
| 1023 | |
| 1024 void BytecodeGraphBuilder::VisitTailCallICWide() { | |
| 1025 BuildCallWithFeedbackSlot(TailCallMode::kAllow); | |
| 1026 } | |
| 1027 | |
| 1028 void BytecodeGraphBuilder::BuildCall(TailCallMode tail_call_mode) { | |
| 1029 FrameStateBeforeAndAfter states(this); | |
| 1030 // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver | |
| 1031 // register has been loaded with null / undefined explicitly or we are sure it | |
| 1032 // is not null / undefined. | |
| 1033 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; | |
| 1034 Node* callee = | |
| 1035 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | |
| 1036 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); | |
| 1037 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | |
| 1038 | |
| 1039 const Operator* call = javascript()->CallFunction( | |
| 1040 arg_count + 1, VectorSlotPair(), receiver_hint, tail_call_mode); | |
| 1041 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1); | |
| 1042 environment()->BindAccumulator(value, &states); | |
| 1043 } | |
| 1044 | 1013 |
| 1045 void BytecodeGraphBuilder::VisitCall() { BuildCall(TailCallMode::kDisallow); } | 1014 void BytecodeGraphBuilder::VisitCall() { BuildCall(TailCallMode::kDisallow); } |
| 1046 | 1015 |
| 1047 void BytecodeGraphBuilder::VisitCallWide() { | 1016 void BytecodeGraphBuilder::VisitCallWide() { |
| 1048 BuildCall(TailCallMode::kDisallow); | 1017 BuildCall(TailCallMode::kDisallow); |
| 1049 } | 1018 } |
| 1050 | 1019 |
| 1051 void BytecodeGraphBuilder::VisitTailCall() { BuildCall(TailCallMode::kAllow); } | 1020 void BytecodeGraphBuilder::VisitTailCall() { BuildCall(TailCallMode::kAllow); } |
| 1052 | 1021 |
| 1053 void BytecodeGraphBuilder::VisitTailCallWide() { | 1022 void BytecodeGraphBuilder::VisitTailCallWide() { |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 // Phi does not exist yet, introduce one. | 1751 // Phi does not exist yet, introduce one. |
| 1783 value = NewPhi(inputs, value, control); | 1752 value = NewPhi(inputs, value, control); |
| 1784 value->ReplaceInput(inputs - 1, other); | 1753 value->ReplaceInput(inputs - 1, other); |
| 1785 } | 1754 } |
| 1786 return value; | 1755 return value; |
| 1787 } | 1756 } |
| 1788 | 1757 |
| 1789 } // namespace compiler | 1758 } // namespace compiler |
| 1790 } // namespace internal | 1759 } // namespace internal |
| 1791 } // namespace v8 | 1760 } // namespace v8 |
| OLD | NEW |