Chromium Code Reviews| 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 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 895 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
| 896 LGoto* result = new LGoto(instr->FirstSuccessor()->block_id(), | 896 LGoto* result = new LGoto(instr->FirstSuccessor()->block_id(), |
| 897 instr->include_stack_check()); | 897 instr->include_stack_check()); |
| 898 return (instr->include_stack_check()) | 898 return (instr->include_stack_check()) |
| 899 ? AssignPointerMap(result) | 899 ? AssignPointerMap(result) |
| 900 : result; | 900 : result; |
| 901 } | 901 } |
| 902 | 902 |
| 903 | 903 |
| 904 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { | 904 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { |
| 905 Abort("Unimplemented: %s", "DoBranch"); | 905 HValue* v = instr->value(); |
| 906 return NULL; | 906 if (v->EmitAtUses()) { |
| 907 if (v->IsClassOfTest()) { | |
| 908 HClassOfTest* compare = HClassOfTest::cast(v); | |
| 909 ASSERT(compare->value()->representation().IsTagged()); | |
| 910 | |
| 911 return new LClassOfTestAndBranch(UseTempRegister(compare->value()), | |
| 912 TempRegister(), | |
| 913 TempRegister()); | |
| 914 } else if (v->IsCompare()) { | |
| 915 HCompare* compare = HCompare::cast(v); | |
| 916 Token::Value op = compare->token(); | |
| 917 HValue* left = compare->left(); | |
| 918 HValue* right = compare->right(); | |
| 919 Representation r = compare->GetInputRepresentation(); | |
| 920 if (r.IsInteger32()) { | |
| 921 ASSERT(left->representation().IsInteger32()); | |
| 922 ASSERT(right->representation().IsInteger32()); | |
| 923 | |
| 924 return new LCmpIDAndBranch(UseRegisterAtStart(left), | |
|
William Hesse
2011/01/18 14:01:50
I think Integer32 can be handled by the CmpIAndBra
Lasse Reichstein
2011/01/19 09:20:35
I don't believe there is a CmpIAndBranch, only a C
| |
| 925 UseOrConstantAtStart(right)); | |
| 926 } else if (r.IsDouble()) { | |
| 927 ASSERT(left->representation().IsDouble()); | |
| 928 ASSERT(right->representation().IsDouble()); | |
| 929 | |
| 930 return new LCmpIDAndBranch(UseRegisterAtStart(left), | |
| 931 UseRegisterAtStart(right)); | |
| 932 } else { | |
| 933 ASSERT(left->representation().IsTagged()); | |
| 934 ASSERT(right->representation().IsTagged()); | |
| 935 bool reversed = op == Token::GT || op == Token::LTE; | |
| 936 LOperand* left_operand = UseFixed(left, reversed ? rax : rdx); | |
| 937 LOperand* right_operand = UseFixed(right, reversed ? rdx : rax); | |
| 938 LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, | |
| 939 right_operand); | |
| 940 return MarkAsCall(result, instr); | |
| 941 } | |
| 942 } else if (v->IsIsSmi()) { | |
| 943 HIsSmi* compare = HIsSmi::cast(v); | |
| 944 ASSERT(compare->value()->representation().IsTagged()); | |
| 945 | |
| 946 return new LIsSmiAndBranch(Use(compare->value())); | |
| 947 } else if (v->IsHasInstanceType()) { | |
| 948 HHasInstanceType* compare = HHasInstanceType::cast(v); | |
| 949 ASSERT(compare->value()->representation().IsTagged()); | |
| 950 | |
| 951 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()), | |
| 952 TempRegister()); | |
| 953 } else if (v->IsHasCachedArrayIndex()) { | |
| 954 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v); | |
| 955 ASSERT(compare->value()->representation().IsTagged()); | |
| 956 | |
| 957 return new LHasCachedArrayIndexAndBranch( | |
| 958 UseRegisterAtStart(compare->value())); | |
| 959 } else if (v->IsIsNull()) { | |
| 960 HIsNull* compare = HIsNull::cast(v); | |
| 961 ASSERT(compare->value()->representation().IsTagged()); | |
| 962 | |
| 963 // We only need a temp register for non-strict compare. | |
| 964 LOperand* temp = compare->is_strict() ? NULL : TempRegister(); | |
| 965 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), | |
| 966 temp); | |
| 967 } else if (v->IsIsObject()) { | |
| 968 HIsObject* compare = HIsObject::cast(v); | |
| 969 ASSERT(compare->value()->representation().IsTagged()); | |
| 970 | |
| 971 LOperand* temp1 = TempRegister(); | |
| 972 LOperand* temp2 = TempRegister(); | |
| 973 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), | |
| 974 temp1, | |
| 975 temp2); | |
| 976 } else if (v->IsCompareJSObjectEq()) { | |
| 977 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); | |
| 978 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), | |
| 979 UseRegisterAtStart(compare->right())); | |
| 980 } else if (v->IsInstanceOf()) { | |
| 981 HInstanceOf* instance_of = HInstanceOf::cast(v); | |
| 982 LInstanceOfAndBranch* result = | |
| 983 new LInstanceOfAndBranch( | |
| 984 UseFixed(instance_of->left(), InstanceofStub::left()), | |
| 985 UseFixed(instance_of->right(), InstanceofStub::right())); | |
| 986 return MarkAsCall(result, instr); | |
| 987 } else if (v->IsTypeofIs()) { | |
| 988 HTypeofIs* typeof_is = HTypeofIs::cast(v); | |
| 989 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value())); | |
| 990 } else { | |
| 991 if (v->IsConstant()) { | |
| 992 if (HConstant::cast(v)->handle()->IsTrue()) { | |
| 993 return new LGoto(instr->FirstSuccessor()->block_id()); | |
| 994 } else if (HConstant::cast(v)->handle()->IsFalse()) { | |
| 995 return new LGoto(instr->SecondSuccessor()->block_id()); | |
| 996 } | |
| 997 } | |
| 998 Abort("Undefined compare before branch"); | |
| 999 return NULL; | |
| 1000 } | |
| 1001 } | |
| 1002 return new LBranch(UseRegisterAtStart(v)); | |
| 907 } | 1003 } |
| 908 | 1004 |
| 909 | 1005 |
| 910 LInstruction* LChunkBuilder::DoCompareMapAndBranch( | 1006 LInstruction* LChunkBuilder::DoCompareMapAndBranch( |
| 911 HCompareMapAndBranch* instr) { | 1007 HCompareMapAndBranch* instr) { |
| 912 Abort("Unimplemented: %s", "DoCompareMapAndBranch"); | 1008 Abort("Unimplemented: %s", "DoCompareMapAndBranch"); |
| 913 return NULL; | 1009 return NULL; |
| 914 } | 1010 } |
| 915 | 1011 |
| 916 | 1012 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 } | 1186 } |
| 1091 | 1187 |
| 1092 | 1188 |
| 1093 LInstruction* LChunkBuilder::DoPower(HPower* instr) { | 1189 LInstruction* LChunkBuilder::DoPower(HPower* instr) { |
| 1094 Abort("Unimplemented: %s", "DoPower"); | 1190 Abort("Unimplemented: %s", "DoPower"); |
| 1095 return NULL; | 1191 return NULL; |
| 1096 } | 1192 } |
| 1097 | 1193 |
| 1098 | 1194 |
| 1099 LInstruction* LChunkBuilder::DoCompare(HCompare* instr) { | 1195 LInstruction* LChunkBuilder::DoCompare(HCompare* instr) { |
| 1100 Abort("Unimplemented: %s", "DoCompare"); | 1196 Token::Value op = instr->token(); |
| 1101 return NULL; | 1197 Representation r = instr->GetInputRepresentation(); |
| 1198 if (r.IsInteger32()) { | |
| 1199 ASSERT(instr->left()->representation().IsInteger32()); | |
| 1200 ASSERT(instr->right()->representation().IsInteger32()); | |
| 1201 LOperand* left = UseRegisterAtStart(instr->left()); | |
| 1202 LOperand* right = UseOrConstantAtStart(instr->right()); | |
| 1203 return DefineAsRegister(new LCmpID(left, right)); | |
| 1204 } else if (r.IsDouble()) { | |
| 1205 ASSERT(instr->left()->representation().IsDouble()); | |
| 1206 ASSERT(instr->right()->representation().IsDouble()); | |
| 1207 LOperand* left = UseRegisterAtStart(instr->left()); | |
| 1208 LOperand* right = UseRegisterAtStart(instr->right()); | |
| 1209 return DefineAsRegister(new LCmpID(left, right)); | |
| 1210 } else { | |
| 1211 ASSERT(instr->left()->representation().IsTagged()); | |
| 1212 ASSERT(instr->right()->representation().IsTagged()); | |
| 1213 bool reversed = (op == Token::GT || op == Token::LTE); | |
| 1214 LOperand* left = UseFixed(instr->left(), reversed ? rax : rdx); | |
| 1215 LOperand* right = UseFixed(instr->right(), reversed ? rdx : rax); | |
| 1216 LCmpT* result = new LCmpT(left, right); | |
| 1217 return MarkAsCall(DefineFixed(result, rax), instr); | |
| 1218 } | |
| 1102 } | 1219 } |
| 1103 | 1220 |
| 1104 | 1221 |
| 1105 LInstruction* LChunkBuilder::DoCompareJSObjectEq( | 1222 LInstruction* LChunkBuilder::DoCompareJSObjectEq( |
| 1106 HCompareJSObjectEq* instr) { | 1223 HCompareJSObjectEq* instr) { |
| 1107 Abort("Unimplemented: %s", "DoCompareJSObjectEq"); | 1224 Abort("Unimplemented: %s", "DoCompareJSObjectEq"); |
| 1108 return NULL; | 1225 return NULL; |
| 1109 } | 1226 } |
| 1110 | 1227 |
| 1111 | 1228 |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1443 | 1560 |
| 1444 | 1561 |
| 1445 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 1562 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
| 1446 Abort("Unimplemented: %s", "DoLeaveInlined"); | 1563 Abort("Unimplemented: %s", "DoLeaveInlined"); |
| 1447 return NULL; | 1564 return NULL; |
| 1448 } | 1565 } |
| 1449 | 1566 |
| 1450 } } // namespace v8::internal | 1567 } } // namespace v8::internal |
| 1451 | 1568 |
| 1452 #endif // V8_TARGET_ARCH_X64 | 1569 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |