| 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 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1210       bytecode_iterator().GetIndexOperand(operand_index)); | 1210       bytecode_iterator().GetIndexOperand(operand_index)); | 
| 1211   DCHECK_EQ(FeedbackVectorSlotKind::GENERAL, feedback_vector()->GetKind(slot)); | 1211   DCHECK_EQ(FeedbackVectorSlotKind::GENERAL, feedback_vector()->GetKind(slot)); | 
| 1212   Object* feedback = feedback_vector()->Get(slot); | 1212   Object* feedback = feedback_vector()->Get(slot); | 
| 1213   BinaryOperationHint hint = BinaryOperationHint::kAny; | 1213   BinaryOperationHint hint = BinaryOperationHint::kAny; | 
| 1214   if (feedback->IsSmi()) { | 1214   if (feedback->IsSmi()) { | 
| 1215     hint = BinaryOperationHintFromFeedback((Smi::cast(feedback))->value()); | 1215     hint = BinaryOperationHintFromFeedback((Smi::cast(feedback))->value()); | 
| 1216   } | 1216   } | 
| 1217   return hint; | 1217   return hint; | 
| 1218 } | 1218 } | 
| 1219 | 1219 | 
|  | 1220 // Helper function to create compare operation hint from the recorded type | 
|  | 1221 // feedback. | 
|  | 1222 CompareOperationHint BytecodeGraphBuilder::GetCompareOperationHint() { | 
|  | 1223   int slot_index = bytecode_iterator().GetIndexOperand(1); | 
|  | 1224   if (slot_index == 0) { | 
|  | 1225     return CompareOperationHint::kAny; | 
|  | 1226   } | 
|  | 1227   FeedbackVectorSlot slot = | 
|  | 1228       feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1)); | 
|  | 1229   DCHECK_EQ(FeedbackVectorSlotKind::GENERAL, feedback_vector()->GetKind(slot)); | 
|  | 1230   Object* feedback = feedback_vector()->Get(slot); | 
|  | 1231   CompareOperationHint hint = CompareOperationHint::kAny; | 
|  | 1232   if (feedback->IsSmi()) { | 
|  | 1233     hint = CompareOperationHintFromFeedback((Smi::cast(feedback))->value()); | 
|  | 1234   } | 
|  | 1235   return hint; | 
|  | 1236 } | 
|  | 1237 | 
| 1220 void BytecodeGraphBuilder::VisitAdd() { | 1238 void BytecodeGraphBuilder::VisitAdd() { | 
| 1221   BuildBinaryOp( | 1239   BuildBinaryOp( | 
| 1222       javascript()->Add(GetBinaryOperationHint(kBinaryOperationHintIndex))); | 1240       javascript()->Add(GetBinaryOperationHint(kBinaryOperationHintIndex))); | 
| 1223 } | 1241 } | 
| 1224 | 1242 | 
| 1225 void BytecodeGraphBuilder::VisitSub() { | 1243 void BytecodeGraphBuilder::VisitSub() { | 
| 1226   BuildBinaryOp(javascript()->Subtract( | 1244   BuildBinaryOp(javascript()->Subtract( | 
| 1227       GetBinaryOperationHint(kBinaryOperationHintIndex))); | 1245       GetBinaryOperationHint(kBinaryOperationHintIndex))); | 
| 1228 } | 1246 } | 
| 1229 | 1247 | 
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1373 void BytecodeGraphBuilder::BuildCompareOp(const Operator* js_op) { | 1391 void BytecodeGraphBuilder::BuildCompareOp(const Operator* js_op) { | 
| 1374   FrameStateBeforeAndAfter states(this); | 1392   FrameStateBeforeAndAfter states(this); | 
| 1375   Node* left = | 1393   Node* left = | 
| 1376       environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1394       environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 
| 1377   Node* right = environment()->LookupAccumulator(); | 1395   Node* right = environment()->LookupAccumulator(); | 
| 1378   Node* node = NewNode(js_op, left, right); | 1396   Node* node = NewNode(js_op, left, right); | 
| 1379   environment()->BindAccumulator(node, &states); | 1397   environment()->BindAccumulator(node, &states); | 
| 1380 } | 1398 } | 
| 1381 | 1399 | 
| 1382 void BytecodeGraphBuilder::VisitTestEqual() { | 1400 void BytecodeGraphBuilder::VisitTestEqual() { | 
| 1383   CompareOperationHint hint = CompareOperationHint::kAny; | 1401   BuildCompareOp(javascript()->Equal(GetCompareOperationHint())); | 
| 1384   BuildCompareOp(javascript()->Equal(hint)); |  | 
| 1385 } | 1402 } | 
| 1386 | 1403 | 
| 1387 void BytecodeGraphBuilder::VisitTestNotEqual() { | 1404 void BytecodeGraphBuilder::VisitTestNotEqual() { | 
| 1388   CompareOperationHint hint = CompareOperationHint::kAny; | 1405   BuildCompareOp(javascript()->NotEqual(GetCompareOperationHint())); | 
| 1389   BuildCompareOp(javascript()->NotEqual(hint)); |  | 
| 1390 } | 1406 } | 
| 1391 | 1407 | 
| 1392 void BytecodeGraphBuilder::VisitTestEqualStrict() { | 1408 void BytecodeGraphBuilder::VisitTestEqualStrict() { | 
| 1393   CompareOperationHint hint = CompareOperationHint::kAny; | 1409   BuildCompareOp(javascript()->StrictEqual(GetCompareOperationHint())); | 
| 1394   BuildCompareOp(javascript()->StrictEqual(hint)); |  | 
| 1395 } | 1410 } | 
| 1396 | 1411 | 
| 1397 void BytecodeGraphBuilder::VisitTestLessThan() { | 1412 void BytecodeGraphBuilder::VisitTestLessThan() { | 
| 1398   CompareOperationHint hint = CompareOperationHint::kAny; | 1413   BuildCompareOp(javascript()->LessThan(GetCompareOperationHint())); | 
| 1399   BuildCompareOp(javascript()->LessThan(hint)); |  | 
| 1400 } | 1414 } | 
| 1401 | 1415 | 
| 1402 void BytecodeGraphBuilder::VisitTestGreaterThan() { | 1416 void BytecodeGraphBuilder::VisitTestGreaterThan() { | 
| 1403   CompareOperationHint hint = CompareOperationHint::kAny; | 1417   BuildCompareOp(javascript()->GreaterThan(GetCompareOperationHint())); | 
| 1404   BuildCompareOp(javascript()->GreaterThan(hint)); |  | 
| 1405 } | 1418 } | 
| 1406 | 1419 | 
| 1407 void BytecodeGraphBuilder::VisitTestLessThanOrEqual() { | 1420 void BytecodeGraphBuilder::VisitTestLessThanOrEqual() { | 
| 1408   CompareOperationHint hint = CompareOperationHint::kAny; | 1421   BuildCompareOp(javascript()->LessThanOrEqual(GetCompareOperationHint())); | 
| 1409   BuildCompareOp(javascript()->LessThanOrEqual(hint)); |  | 
| 1410 } | 1422 } | 
| 1411 | 1423 | 
| 1412 void BytecodeGraphBuilder::VisitTestGreaterThanOrEqual() { | 1424 void BytecodeGraphBuilder::VisitTestGreaterThanOrEqual() { | 
| 1413   CompareOperationHint hint = CompareOperationHint::kAny; | 1425   BuildCompareOp(javascript()->GreaterThanOrEqual(GetCompareOperationHint())); | 
| 1414   BuildCompareOp(javascript()->GreaterThanOrEqual(hint)); |  | 
| 1415 } | 1426 } | 
| 1416 | 1427 | 
| 1417 void BytecodeGraphBuilder::VisitTestIn() { | 1428 void BytecodeGraphBuilder::VisitTestIn() { | 
| 1418   BuildCompareOp(javascript()->HasProperty()); | 1429   BuildCompareOp(javascript()->HasProperty()); | 
| 1419 } | 1430 } | 
| 1420 | 1431 | 
| 1421 void BytecodeGraphBuilder::VisitTestInstanceOf() { | 1432 void BytecodeGraphBuilder::VisitTestInstanceOf() { | 
| 1422   BuildCompareOp(javascript()->InstanceOf()); | 1433   BuildCompareOp(javascript()->InstanceOf()); | 
| 1423 } | 1434 } | 
| 1424 | 1435 | 
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1934     // Phi does not exist yet, introduce one. | 1945     // Phi does not exist yet, introduce one. | 
| 1935     value = NewPhi(inputs, value, control); | 1946     value = NewPhi(inputs, value, control); | 
| 1936     value->ReplaceInput(inputs - 1, other); | 1947     value->ReplaceInput(inputs - 1, other); | 
| 1937   } | 1948   } | 
| 1938   return value; | 1949   return value; | 
| 1939 } | 1950 } | 
| 1940 | 1951 | 
| 1941 }  // namespace compiler | 1952 }  // namespace compiler | 
| 1942 }  // namespace internal | 1953 }  // namespace internal | 
| 1943 }  // namespace v8 | 1954 }  // namespace v8 | 
| OLD | NEW | 
|---|