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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 } | 1129 } |
1130 | 1130 |
1131 void BytecodeGraphBuilder::VisitCallRuntimeForPair() { | 1131 void BytecodeGraphBuilder::VisitCallRuntimeForPair() { |
1132 BuildCallRuntimeForPair(); | 1132 BuildCallRuntimeForPair(); |
1133 } | 1133 } |
1134 | 1134 |
1135 void BytecodeGraphBuilder::VisitCallRuntimeForPairWide() { | 1135 void BytecodeGraphBuilder::VisitCallRuntimeForPairWide() { |
1136 BuildCallRuntimeForPair(); | 1136 BuildCallRuntimeForPair(); |
1137 } | 1137 } |
1138 | 1138 |
1139 | |
1140 Node* BytecodeGraphBuilder::ProcessCallNewArguments( | 1139 Node* BytecodeGraphBuilder::ProcessCallNewArguments( |
1141 const Operator* call_new_op, interpreter::Register callee, | 1140 const Operator* call_new_op, Node* callee, Node* new_target, |
1142 interpreter::Register first_arg, size_t arity) { | 1141 interpreter::Register first_arg, size_t arity) { |
1143 Node** all = info()->zone()->NewArray<Node*>(arity); | 1142 Node** all = info()->zone()->NewArray<Node*>(arity); |
1144 all[0] = environment()->LookupRegister(callee); | 1143 all[0] = new_target; |
1145 int first_arg_index = first_arg.index(); | 1144 int first_arg_index = first_arg.index(); |
1146 for (int i = 1; i < static_cast<int>(arity) - 1; ++i) { | 1145 for (int i = 1; i < static_cast<int>(arity) - 1; ++i) { |
1147 all[i] = environment()->LookupRegister( | 1146 all[i] = environment()->LookupRegister( |
1148 interpreter::Register(first_arg_index + i - 1)); | 1147 interpreter::Register(first_arg_index + i - 1)); |
1149 } | 1148 } |
1150 // Original constructor is the same as the callee. | 1149 all[arity - 1] = callee; |
1151 all[arity - 1] = environment()->LookupRegister(callee); | |
1152 Node* value = MakeNode(call_new_op, static_cast<int>(arity), all, false); | 1150 Node* value = MakeNode(call_new_op, static_cast<int>(arity), all, false); |
1153 return value; | 1151 return value; |
1154 } | 1152 } |
1155 | 1153 |
1156 void BytecodeGraphBuilder::BuildCallConstruct() { | 1154 void BytecodeGraphBuilder::BuildCallConstruct() { |
1157 FrameStateBeforeAndAfter states(this); | 1155 FrameStateBeforeAndAfter states(this); |
1158 interpreter::Register callee = bytecode_iterator().GetRegisterOperand(0); | 1156 interpreter::Register callee_reg = bytecode_iterator().GetRegisterOperand(0); |
1159 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); | 1157 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
1160 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); | 1158 size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); |
1161 | 1159 |
| 1160 Node* new_target = environment()->LookupAccumulator(); |
| 1161 Node* callee = environment()->LookupRegister(callee_reg); |
1162 // TODO(turbofan): Pass the feedback here. | 1162 // TODO(turbofan): Pass the feedback here. |
1163 const Operator* call = javascript()->CallConstruct( | 1163 const Operator* call = javascript()->CallConstruct( |
1164 static_cast<int>(arg_count) + 2, VectorSlotPair()); | 1164 static_cast<int>(arg_count) + 2, VectorSlotPair()); |
1165 Node* value = ProcessCallNewArguments(call, callee, first_arg, arg_count + 2); | 1165 Node* value = ProcessCallNewArguments(call, callee, new_target, first_arg, |
| 1166 arg_count + 2); |
1166 environment()->BindAccumulator(value, &states); | 1167 environment()->BindAccumulator(value, &states); |
1167 } | 1168 } |
1168 | 1169 |
1169 void BytecodeGraphBuilder::VisitNew() { BuildCallConstruct(); } | 1170 void BytecodeGraphBuilder::VisitNew() { BuildCallConstruct(); } |
1170 | 1171 |
1171 void BytecodeGraphBuilder::VisitNewWide() { BuildCallConstruct(); } | 1172 void BytecodeGraphBuilder::VisitNewWide() { BuildCallConstruct(); } |
1172 | 1173 |
1173 void BytecodeGraphBuilder::BuildThrow() { | 1174 void BytecodeGraphBuilder::BuildThrow() { |
1174 FrameStateBeforeAndAfter states(this); | 1175 FrameStateBeforeAndAfter states(this); |
1175 Node* value = environment()->LookupAccumulator(); | 1176 Node* value = environment()->LookupAccumulator(); |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 // Phi does not exist yet, introduce one. | 1796 // Phi does not exist yet, introduce one. |
1796 value = NewPhi(inputs, value, control); | 1797 value = NewPhi(inputs, value, control); |
1797 value->ReplaceInput(inputs - 1, other); | 1798 value->ReplaceInput(inputs - 1, other); |
1798 } | 1799 } |
1799 return value; | 1800 return value; |
1800 } | 1801 } |
1801 | 1802 |
1802 } // namespace compiler | 1803 } // namespace compiler |
1803 } // namespace internal | 1804 } // namespace internal |
1804 } // namespace v8 | 1805 } // namespace v8 |
OLD | NEW |