OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 906 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
907 LGoto* result = new LGoto(instr->FirstSuccessor()->block_id(), | 907 LGoto* result = new LGoto(instr->FirstSuccessor()->block_id(), |
908 instr->include_stack_check()); | 908 instr->include_stack_check()); |
909 return (instr->include_stack_check()) | 909 return (instr->include_stack_check()) |
910 ? AssignPointerMap(result) | 910 ? AssignPointerMap(result) |
911 : result; | 911 : result; |
912 } | 912 } |
913 | 913 |
914 | 914 |
915 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { | 915 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { |
916 Abort("Unimplemented: %s", "DoBranch"); | 916 HValue* v = instr->value(); |
917 return NULL; | 917 if (v->EmitAtUses()) { |
| 918 if (v->IsClassOfTest()) { |
| 919 HClassOfTest* compare = HClassOfTest::cast(v); |
| 920 ASSERT(compare->value()->representation().IsTagged()); |
| 921 |
| 922 return new LClassOfTestAndBranch(UseTempRegister(compare->value()), |
| 923 TempRegister()); |
| 924 } else if (v->IsCompare()) { |
| 925 HCompare* compare = HCompare::cast(v); |
| 926 Token::Value op = compare->token(); |
| 927 HValue* left = compare->left(); |
| 928 HValue* right = compare->right(); |
| 929 Representation r = compare->GetInputRepresentation(); |
| 930 if (r.IsInteger32()) { |
| 931 ASSERT(left->representation().IsInteger32()); |
| 932 ASSERT(right->representation().IsInteger32()); |
| 933 |
| 934 return new LCmpIDAndBranch(UseRegisterAtStart(left), |
| 935 UseOrConstantAtStart(right)); |
| 936 } else if (r.IsDouble()) { |
| 937 ASSERT(left->representation().IsDouble()); |
| 938 ASSERT(right->representation().IsDouble()); |
| 939 |
| 940 return new LCmpIDAndBranch(UseRegisterAtStart(left), |
| 941 UseRegisterAtStart(right)); |
| 942 } else { |
| 943 ASSERT(left->representation().IsTagged()); |
| 944 ASSERT(right->representation().IsTagged()); |
| 945 bool reversed = op == Token::GT || op == Token::LTE; |
| 946 LOperand* left_operand = UseFixed(left, reversed ? rax : rdx); |
| 947 LOperand* right_operand = UseFixed(right, reversed ? rdx : rax); |
| 948 LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, |
| 949 right_operand); |
| 950 return MarkAsCall(result, instr); |
| 951 } |
| 952 } else if (v->IsIsSmi()) { |
| 953 HIsSmi* compare = HIsSmi::cast(v); |
| 954 ASSERT(compare->value()->representation().IsTagged()); |
| 955 |
| 956 return new LIsSmiAndBranch(Use(compare->value())); |
| 957 } else if (v->IsHasInstanceType()) { |
| 958 HHasInstanceType* compare = HHasInstanceType::cast(v); |
| 959 ASSERT(compare->value()->representation().IsTagged()); |
| 960 |
| 961 return new LHasInstanceTypeAndBranch( |
| 962 UseRegisterAtStart(compare->value())); |
| 963 } else if (v->IsHasCachedArrayIndex()) { |
| 964 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v); |
| 965 ASSERT(compare->value()->representation().IsTagged()); |
| 966 |
| 967 return new LHasCachedArrayIndexAndBranch( |
| 968 UseRegisterAtStart(compare->value())); |
| 969 } else if (v->IsIsNull()) { |
| 970 HIsNull* compare = HIsNull::cast(v); |
| 971 ASSERT(compare->value()->representation().IsTagged()); |
| 972 |
| 973 // We only need a temp register for non-strict compare. |
| 974 LOperand* temp = compare->is_strict() ? NULL : TempRegister(); |
| 975 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), |
| 976 temp); |
| 977 } else if (v->IsIsObject()) { |
| 978 HIsObject* compare = HIsObject::cast(v); |
| 979 ASSERT(compare->value()->representation().IsTagged()); |
| 980 |
| 981 LOperand* temp1 = TempRegister(); |
| 982 LOperand* temp2 = TempRegister(); |
| 983 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), |
| 984 temp1, |
| 985 temp2); |
| 986 } else if (v->IsCompareJSObjectEq()) { |
| 987 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); |
| 988 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), |
| 989 UseRegisterAtStart(compare->right())); |
| 990 } else if (v->IsInstanceOf()) { |
| 991 HInstanceOf* instance_of = HInstanceOf::cast(v); |
| 992 LInstanceOfAndBranch* result = |
| 993 new LInstanceOfAndBranch( |
| 994 UseFixed(instance_of->left(), InstanceofStub::left()), |
| 995 UseFixed(instance_of->right(), InstanceofStub::right())); |
| 996 return MarkAsCall(result, instr); |
| 997 } else if (v->IsTypeofIs()) { |
| 998 HTypeofIs* typeof_is = HTypeofIs::cast(v); |
| 999 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value())); |
| 1000 } else { |
| 1001 if (v->IsConstant()) { |
| 1002 if (HConstant::cast(v)->handle()->IsTrue()) { |
| 1003 return new LGoto(instr->FirstSuccessor()->block_id()); |
| 1004 } else if (HConstant::cast(v)->handle()->IsFalse()) { |
| 1005 return new LGoto(instr->SecondSuccessor()->block_id()); |
| 1006 } |
| 1007 } |
| 1008 Abort("Undefined compare before branch"); |
| 1009 return NULL; |
| 1010 } |
| 1011 } |
| 1012 return new LBranch(UseRegisterAtStart(v)); |
918 } | 1013 } |
919 | 1014 |
920 | 1015 |
921 LInstruction* LChunkBuilder::DoCompareMapAndBranch( | 1016 LInstruction* LChunkBuilder::DoCompareMapAndBranch( |
922 HCompareMapAndBranch* instr) { | 1017 HCompareMapAndBranch* instr) { |
923 Abort("Unimplemented: %s", "DoCompareMapAndBranch"); | 1018 Abort("Unimplemented: %s", "DoCompareMapAndBranch"); |
924 return NULL; | 1019 return NULL; |
925 } | 1020 } |
926 | 1021 |
927 | 1022 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 } | 1212 } |
1118 | 1213 |
1119 | 1214 |
1120 LInstruction* LChunkBuilder::DoPower(HPower* instr) { | 1215 LInstruction* LChunkBuilder::DoPower(HPower* instr) { |
1121 Abort("Unimplemented: %s", "DoPower"); | 1216 Abort("Unimplemented: %s", "DoPower"); |
1122 return NULL; | 1217 return NULL; |
1123 } | 1218 } |
1124 | 1219 |
1125 | 1220 |
1126 LInstruction* LChunkBuilder::DoCompare(HCompare* instr) { | 1221 LInstruction* LChunkBuilder::DoCompare(HCompare* instr) { |
1127 Abort("Unimplemented: %s", "DoCompare"); | 1222 Token::Value op = instr->token(); |
1128 return NULL; | 1223 Representation r = instr->GetInputRepresentation(); |
| 1224 if (r.IsInteger32()) { |
| 1225 ASSERT(instr->left()->representation().IsInteger32()); |
| 1226 ASSERT(instr->right()->representation().IsInteger32()); |
| 1227 LOperand* left = UseRegisterAtStart(instr->left()); |
| 1228 LOperand* right = UseOrConstantAtStart(instr->right()); |
| 1229 return DefineAsRegister(new LCmpID(left, right)); |
| 1230 } else if (r.IsDouble()) { |
| 1231 ASSERT(instr->left()->representation().IsDouble()); |
| 1232 ASSERT(instr->right()->representation().IsDouble()); |
| 1233 LOperand* left = UseRegisterAtStart(instr->left()); |
| 1234 LOperand* right = UseRegisterAtStart(instr->right()); |
| 1235 return DefineAsRegister(new LCmpID(left, right)); |
| 1236 } else { |
| 1237 ASSERT(instr->left()->representation().IsTagged()); |
| 1238 ASSERT(instr->right()->representation().IsTagged()); |
| 1239 bool reversed = (op == Token::GT || op == Token::LTE); |
| 1240 LOperand* left = UseFixed(instr->left(), reversed ? rax : rdx); |
| 1241 LOperand* right = UseFixed(instr->right(), reversed ? rdx : rax); |
| 1242 LCmpT* result = new LCmpT(left, right); |
| 1243 return MarkAsCall(DefineFixed(result, rax), instr); |
| 1244 } |
1129 } | 1245 } |
1130 | 1246 |
1131 | 1247 |
1132 LInstruction* LChunkBuilder::DoCompareJSObjectEq( | 1248 LInstruction* LChunkBuilder::DoCompareJSObjectEq( |
1133 HCompareJSObjectEq* instr) { | 1249 HCompareJSObjectEq* instr) { |
1134 Abort("Unimplemented: %s", "DoCompareJSObjectEq"); | 1250 Abort("Unimplemented: %s", "DoCompareJSObjectEq"); |
1135 return NULL; | 1251 return NULL; |
1136 } | 1252 } |
1137 | 1253 |
1138 | 1254 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 | 1586 |
1471 | 1587 |
1472 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 1588 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
1473 Abort("Unimplemented: %s", "DoLeaveInlined"); | 1589 Abort("Unimplemented: %s", "DoLeaveInlined"); |
1474 return NULL; | 1590 return NULL; |
1475 } | 1591 } |
1476 | 1592 |
1477 } } // namespace v8::internal | 1593 } } // namespace v8::internal |
1478 | 1594 |
1479 #endif // V8_TARGET_ARCH_X64 | 1595 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |