| 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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 if (current->has_position()) position_ = current->position(); | 840 if (current->has_position()) position_ = current->position(); |
| 841 LInstruction* instr = current->CompileToLithium(this); | 841 LInstruction* instr = current->CompileToLithium(this); |
| 842 | 842 |
| 843 if (instr != NULL) { | 843 if (instr != NULL) { |
| 844 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | 844 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
| 845 instr = AssignPointerMap(instr); | 845 instr = AssignPointerMap(instr); |
| 846 } | 846 } |
| 847 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 847 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 848 instr = AssignEnvironment(instr); | 848 instr = AssignEnvironment(instr); |
| 849 } | 849 } |
| 850 if (current->IsBranch() && !instr->IsGoto()) { | 850 if (current->IsTest() && !instr->IsGoto()) { |
| 851 // TODO(fschneider): Handle branch instructions uniformly like | |
| 852 // other instructions. This requires us to generate the right | |
| 853 // branch instruction already at the HIR level. | |
| 854 ASSERT(instr->IsControl()); | 851 ASSERT(instr->IsControl()); |
| 855 HBranch* branch = HBranch::cast(current); | 852 HTest* test = HTest::cast(current); |
| 856 instr->set_hydrogen_value(branch->value()); | 853 instr->set_hydrogen_value(test->value()); |
| 857 HBasicBlock* first = branch->FirstSuccessor(); | 854 HBasicBlock* first = test->FirstSuccessor(); |
| 858 HBasicBlock* second = branch->SecondSuccessor(); | 855 HBasicBlock* second = test->SecondSuccessor(); |
| 859 ASSERT(first != NULL && second != NULL); | 856 ASSERT(first != NULL && second != NULL); |
| 860 instr->SetBranchTargets(first->block_id(), second->block_id()); | 857 instr->SetBranchTargets(first->block_id(), second->block_id()); |
| 861 } else { | 858 } else { |
| 862 instr->set_hydrogen_value(current); | 859 instr->set_hydrogen_value(current); |
| 863 } | 860 } |
| 864 | 861 |
| 865 int index = chunk_->AddInstruction(instr, current_block_); | 862 int index = chunk_->AddInstruction(instr, current_block_); |
| 866 allocator_->SummarizeInstruction(index); | 863 allocator_->SummarizeInstruction(index); |
| 867 } else { | 864 } else { |
| 868 // This instruction should be omitted. | 865 // This instruction should be omitted. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 | 902 |
| 906 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 903 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
| 907 LGoto* result = new LGoto(instr->FirstSuccessor()->block_id(), | 904 LGoto* result = new LGoto(instr->FirstSuccessor()->block_id(), |
| 908 instr->include_stack_check()); | 905 instr->include_stack_check()); |
| 909 return (instr->include_stack_check()) | 906 return (instr->include_stack_check()) |
| 910 ? AssignPointerMap(result) | 907 ? AssignPointerMap(result) |
| 911 : result; | 908 : result; |
| 912 } | 909 } |
| 913 | 910 |
| 914 | 911 |
| 915 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { | 912 LInstruction* LChunkBuilder::DoTest(HTest* instr) { |
| 916 Abort("Unimplemented: %s", "DoBranch"); | 913 HValue* v = instr->value(); |
| 914 if (v->EmitAtUses()) { |
| 915 if (v->IsClassOfTest()) { |
| 916 HClassOfTest* compare = HClassOfTest::cast(v); |
| 917 ASSERT(compare->value()->representation().IsTagged()); |
| 918 |
| 919 return new LClassOfTestAndBranch(UseTempRegister(compare->value()), |
| 920 TempRegister()); |
| 921 } else if (v->IsCompare()) { |
| 922 HCompare* compare = HCompare::cast(v); |
| 923 Token::Value op = compare->token(); |
| 924 HValue* left = compare->left(); |
| 925 HValue* right = compare->right(); |
| 926 Representation r = compare->GetInputRepresentation(); |
| 927 if (r.IsInteger32()) { |
| 928 ASSERT(left->representation().IsInteger32()); |
| 929 ASSERT(right->representation().IsInteger32()); |
| 930 |
| 931 return new LCmpIDAndBranch(UseRegisterAtStart(left), |
| 932 UseOrConstantAtStart(right)); |
| 933 } else if (r.IsDouble()) { |
| 934 ASSERT(left->representation().IsDouble()); |
| 935 ASSERT(right->representation().IsDouble()); |
| 936 |
| 937 return new LCmpIDAndBranch(UseRegisterAtStart(left), |
| 938 UseRegisterAtStart(right)); |
| 939 } else { |
| 940 ASSERT(left->representation().IsTagged()); |
| 941 ASSERT(right->representation().IsTagged()); |
| 942 bool reversed = op == Token::GT || op == Token::LTE; |
| 943 LOperand* left_operand = UseFixed(left, reversed ? rax : rdx); |
| 944 LOperand* right_operand = UseFixed(right, reversed ? rdx : rax); |
| 945 LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, |
| 946 right_operand); |
| 947 return MarkAsCall(result, instr); |
| 948 } |
| 949 } else if (v->IsIsSmi()) { |
| 950 HIsSmi* compare = HIsSmi::cast(v); |
| 951 ASSERT(compare->value()->representation().IsTagged()); |
| 952 |
| 953 return new LIsSmiAndBranch(Use(compare->value())); |
| 954 } else if (v->IsHasInstanceType()) { |
| 955 HHasInstanceType* compare = HHasInstanceType::cast(v); |
| 956 ASSERT(compare->value()->representation().IsTagged()); |
| 957 |
| 958 return new LHasInstanceTypeAndBranch( |
| 959 UseRegisterAtStart(compare->value())); |
| 960 } else if (v->IsHasCachedArrayIndex()) { |
| 961 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v); |
| 962 ASSERT(compare->value()->representation().IsTagged()); |
| 963 |
| 964 return new LHasCachedArrayIndexAndBranch( |
| 965 UseRegisterAtStart(compare->value())); |
| 966 } else if (v->IsIsNull()) { |
| 967 HIsNull* compare = HIsNull::cast(v); |
| 968 ASSERT(compare->value()->representation().IsTagged()); |
| 969 |
| 970 // We only need a temp register for non-strict compare. |
| 971 LOperand* temp = compare->is_strict() ? NULL : TempRegister(); |
| 972 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), |
| 973 temp); |
| 974 } else if (v->IsIsObject()) { |
| 975 HIsObject* compare = HIsObject::cast(v); |
| 976 ASSERT(compare->value()->representation().IsTagged()); |
| 977 |
| 978 LOperand* temp1 = TempRegister(); |
| 979 LOperand* temp2 = TempRegister(); |
| 980 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), |
| 981 temp1, |
| 982 temp2); |
| 983 } else if (v->IsCompareJSObjectEq()) { |
| 984 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); |
| 985 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), |
| 986 UseRegisterAtStart(compare->right())); |
| 987 } else if (v->IsInstanceOf()) { |
| 988 HInstanceOf* instance_of = HInstanceOf::cast(v); |
| 989 LInstanceOfAndBranch* result = |
| 990 new LInstanceOfAndBranch( |
| 991 UseFixed(instance_of->left(), InstanceofStub::left()), |
| 992 UseFixed(instance_of->right(), InstanceofStub::right())); |
| 993 return MarkAsCall(result, instr); |
| 994 } else if (v->IsTypeofIs()) { |
| 995 HTypeofIs* typeof_is = HTypeofIs::cast(v); |
| 996 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value())); |
| 997 } else { |
| 998 if (v->IsConstant()) { |
| 999 if (HConstant::cast(v)->handle()->IsTrue()) { |
| 1000 return new LGoto(instr->FirstSuccessor()->block_id()); |
| 1001 } else if (HConstant::cast(v)->handle()->IsFalse()) { |
| 1002 return new LGoto(instr->SecondSuccessor()->block_id()); |
| 1003 } |
| 1004 } |
| 1005 Abort("Undefined compare before branch"); |
| 1006 return NULL; |
| 1007 } |
| 1008 } |
| 1009 return new LBranch(UseRegisterAtStart(v)); |
| 1010 } |
| 1011 |
| 1012 |
| 1013 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { |
| 1014 Abort("Unimplemented: %s", "DoCompareMap"); |
| 917 return NULL; | 1015 return NULL; |
| 918 } | 1016 } |
| 919 | 1017 |
| 920 | |
| 921 LInstruction* LChunkBuilder::DoCompareMapAndBranch( | |
| 922 HCompareMapAndBranch* instr) { | |
| 923 Abort("Unimplemented: %s", "DoCompareMapAndBranch"); | |
| 924 return NULL; | |
| 925 } | |
| 926 | |
| 927 | 1018 |
| 928 LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) { | 1019 LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) { |
| 929 Abort("Unimplemented: %s", "DoArgumentsLength"); | 1020 Abort("Unimplemented: %s", "DoArgumentsLength"); |
| 930 return NULL; | 1021 return NULL; |
| 931 } | 1022 } |
| 932 | 1023 |
| 933 | 1024 |
| 934 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) { | 1025 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) { |
| 935 Abort("Unimplemented: %s", "DoArgumentsElements"); | 1026 Abort("Unimplemented: %s", "DoArgumentsElements"); |
| 936 return NULL; | 1027 return NULL; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 } | 1208 } |
| 1118 | 1209 |
| 1119 | 1210 |
| 1120 LInstruction* LChunkBuilder::DoPower(HPower* instr) { | 1211 LInstruction* LChunkBuilder::DoPower(HPower* instr) { |
| 1121 Abort("Unimplemented: %s", "DoPower"); | 1212 Abort("Unimplemented: %s", "DoPower"); |
| 1122 return NULL; | 1213 return NULL; |
| 1123 } | 1214 } |
| 1124 | 1215 |
| 1125 | 1216 |
| 1126 LInstruction* LChunkBuilder::DoCompare(HCompare* instr) { | 1217 LInstruction* LChunkBuilder::DoCompare(HCompare* instr) { |
| 1127 Abort("Unimplemented: %s", "DoCompare"); | 1218 Token::Value op = instr->token(); |
| 1128 return NULL; | 1219 Representation r = instr->GetInputRepresentation(); |
| 1220 if (r.IsInteger32()) { |
| 1221 ASSERT(instr->left()->representation().IsInteger32()); |
| 1222 ASSERT(instr->right()->representation().IsInteger32()); |
| 1223 LOperand* left = UseRegisterAtStart(instr->left()); |
| 1224 LOperand* right = UseOrConstantAtStart(instr->right()); |
| 1225 return DefineAsRegister(new LCmpID(left, right)); |
| 1226 } else if (r.IsDouble()) { |
| 1227 ASSERT(instr->left()->representation().IsDouble()); |
| 1228 ASSERT(instr->right()->representation().IsDouble()); |
| 1229 LOperand* left = UseRegisterAtStart(instr->left()); |
| 1230 LOperand* right = UseRegisterAtStart(instr->right()); |
| 1231 return DefineAsRegister(new LCmpID(left, right)); |
| 1232 } else { |
| 1233 ASSERT(instr->left()->representation().IsTagged()); |
| 1234 ASSERT(instr->right()->representation().IsTagged()); |
| 1235 bool reversed = (op == Token::GT || op == Token::LTE); |
| 1236 LOperand* left = UseFixed(instr->left(), reversed ? rax : rdx); |
| 1237 LOperand* right = UseFixed(instr->right(), reversed ? rdx : rax); |
| 1238 LCmpT* result = new LCmpT(left, right); |
| 1239 return MarkAsCall(DefineFixed(result, rax), instr); |
| 1240 } |
| 1129 } | 1241 } |
| 1130 | 1242 |
| 1131 | 1243 |
| 1132 LInstruction* LChunkBuilder::DoCompareJSObjectEq( | 1244 LInstruction* LChunkBuilder::DoCompareJSObjectEq( |
| 1133 HCompareJSObjectEq* instr) { | 1245 HCompareJSObjectEq* instr) { |
| 1134 Abort("Unimplemented: %s", "DoCompareJSObjectEq"); | 1246 Abort("Unimplemented: %s", "DoCompareJSObjectEq"); |
| 1135 return NULL; | 1247 return NULL; |
| 1136 } | 1248 } |
| 1137 | 1249 |
| 1138 | 1250 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 return NULL; | 1454 return NULL; |
| 1343 } | 1455 } |
| 1344 | 1456 |
| 1345 | 1457 |
| 1346 LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { | 1458 LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { |
| 1347 Abort("Unimplemented: %s", "DoStoreNamedGeneric"); | 1459 Abort("Unimplemented: %s", "DoStoreNamedGeneric"); |
| 1348 return NULL; | 1460 return NULL; |
| 1349 } | 1461 } |
| 1350 | 1462 |
| 1351 | 1463 |
| 1464 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) { |
| 1465 Abort("Unimplemented: %s", "DoStringCharCodeAt"); |
| 1466 return NULL; |
| 1467 } |
| 1468 |
| 1469 |
| 1470 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { |
| 1471 Abort("Unimplemented: %s", "DoStringLength"); |
| 1472 return NULL; |
| 1473 } |
| 1474 |
| 1475 |
| 1352 LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) { | 1476 LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) { |
| 1353 Abort("Unimplemented: %s", "DoArrayLiteral"); | 1477 Abort("Unimplemented: %s", "DoArrayLiteral"); |
| 1354 return NULL; | 1478 return NULL; |
| 1355 } | 1479 } |
| 1356 | 1480 |
| 1357 | 1481 |
| 1358 LInstruction* LChunkBuilder::DoObjectLiteral(HObjectLiteral* instr) { | 1482 LInstruction* LChunkBuilder::DoObjectLiteral(HObjectLiteral* instr) { |
| 1359 Abort("Unimplemented: %s", "DoObjectLiteral"); | 1483 Abort("Unimplemented: %s", "DoObjectLiteral"); |
| 1360 return NULL; | 1484 return NULL; |
| 1361 } | 1485 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 | 1594 |
| 1471 | 1595 |
| 1472 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 1596 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
| 1473 Abort("Unimplemented: %s", "DoLeaveInlined"); | 1597 Abort("Unimplemented: %s", "DoLeaveInlined"); |
| 1474 return NULL; | 1598 return NULL; |
| 1475 } | 1599 } |
| 1476 | 1600 |
| 1477 } } // namespace v8::internal | 1601 } } // namespace v8::internal |
| 1478 | 1602 |
| 1479 #endif // V8_TARGET_ARCH_X64 | 1603 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |