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 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 LGoto* result = new LGoto(instr->FirstSuccessor()->block_id(), | 1039 LGoto* result = new LGoto(instr->FirstSuccessor()->block_id(), |
1040 instr->include_stack_check()); | 1040 instr->include_stack_check()); |
1041 return (instr->include_stack_check()) | 1041 return (instr->include_stack_check()) |
1042 ? AssignPointerMap(result) | 1042 ? AssignPointerMap(result) |
1043 : result; | 1043 : result; |
1044 } | 1044 } |
1045 | 1045 |
1046 | 1046 |
1047 LInstruction* LChunkBuilder::DoTest(HTest* instr) { | 1047 LInstruction* LChunkBuilder::DoTest(HTest* instr) { |
1048 HValue* v = instr->value(); | 1048 HValue* v = instr->value(); |
1049 if (v->EmitAtUses()) { | 1049 if (!v->EmitAtUses()) { |
1050 if (v->IsClassOfTest()) { | 1050 return new LBranch(UseRegisterAtStart(v)); |
1051 HClassOfTest* compare = HClassOfTest::cast(v); | 1051 } else if (v->IsClassOfTest()) { |
1052 ASSERT(compare->value()->representation().IsTagged()); | 1052 HClassOfTest* compare = HClassOfTest::cast(v); |
1053 | 1053 ASSERT(compare->value()->representation().IsTagged()); |
1054 return new LClassOfTestAndBranch(UseTempRegister(compare->value()), | 1054 return new LClassOfTestAndBranch(UseTempRegister(compare->value()), |
1055 TempRegister()); | 1055 TempRegister()); |
1056 } else if (v->IsCompare()) { | 1056 } else if (v->IsCompare()) { |
1057 HCompare* compare = HCompare::cast(v); | 1057 HCompare* compare = HCompare::cast(v); |
1058 Token::Value op = compare->token(); | 1058 Token::Value op = compare->token(); |
1059 HValue* left = compare->left(); | 1059 HValue* left = compare->left(); |
1060 HValue* right = compare->right(); | 1060 HValue* right = compare->right(); |
1061 Representation r = compare->GetInputRepresentation(); | 1061 Representation r = compare->GetInputRepresentation(); |
1062 if (r.IsInteger32()) { | 1062 if (r.IsInteger32()) { |
1063 ASSERT(left->representation().IsInteger32()); | 1063 ASSERT(left->representation().IsInteger32()); |
1064 ASSERT(right->representation().IsInteger32()); | 1064 ASSERT(right->representation().IsInteger32()); |
1065 | 1065 return new LCmpIDAndBranch(UseRegisterAtStart(left), |
1066 return new LCmpIDAndBranch(UseRegisterAtStart(left), | 1066 UseOrConstantAtStart(right)); |
1067 UseOrConstantAtStart(right)); | 1067 } else if (r.IsDouble()) { |
1068 } else if (r.IsDouble()) { | 1068 ASSERT(left->representation().IsDouble()); |
1069 ASSERT(left->representation().IsDouble()); | 1069 ASSERT(right->representation().IsDouble()); |
1070 ASSERT(right->representation().IsDouble()); | 1070 return new LCmpIDAndBranch(UseRegisterAtStart(left), |
1071 | 1071 UseRegisterAtStart(right)); |
1072 return new LCmpIDAndBranch(UseRegisterAtStart(left), | 1072 } else { |
1073 UseRegisterAtStart(right)); | 1073 ASSERT(left->representation().IsTagged()); |
1074 } else { | 1074 ASSERT(right->representation().IsTagged()); |
1075 ASSERT(left->representation().IsTagged()); | 1075 bool reversed = op == Token::GT || op == Token::LTE; |
1076 ASSERT(right->representation().IsTagged()); | 1076 LOperand* left_operand = UseFixed(left, reversed ? rax : rdx); |
1077 bool reversed = op == Token::GT || op == Token::LTE; | 1077 LOperand* right_operand = UseFixed(right, reversed ? rdx : rax); |
1078 LOperand* left_operand = UseFixed(left, reversed ? rax : rdx); | 1078 LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, right_operand); |
1079 LOperand* right_operand = UseFixed(right, reversed ? rdx : rax); | 1079 return MarkAsCall(result, instr); |
1080 LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, | 1080 } |
1081 right_operand); | 1081 } else if (v->IsIsSmi()) { |
1082 return MarkAsCall(result, instr); | 1082 HIsSmi* compare = HIsSmi::cast(v); |
1083 } | 1083 ASSERT(compare->value()->representation().IsTagged()); |
1084 } else if (v->IsIsSmi()) { | 1084 return new LIsSmiAndBranch(Use(compare->value())); |
1085 HIsSmi* compare = HIsSmi::cast(v); | 1085 } else if (v->IsIsUndetectable()) { |
1086 ASSERT(compare->value()->representation().IsTagged()); | 1086 HIsUndetectable* compare = HIsUndetectable::cast(v); |
1087 | 1087 ASSERT(compare->value()->representation().IsTagged()); |
1088 return new LIsSmiAndBranch(Use(compare->value())); | 1088 return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()), |
1089 } else if (v->IsIsUndetectable()) { | 1089 TempRegister()); |
1090 HIsUndetectable* compare = HIsUndetectable::cast(v); | 1090 } else if (v->IsHasInstanceType()) { |
1091 ASSERT(compare->value()->representation().IsTagged()); | 1091 HHasInstanceType* compare = HHasInstanceType::cast(v); |
1092 | 1092 ASSERT(compare->value()->representation().IsTagged()); |
1093 return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()), | 1093 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value())); |
1094 TempRegister()); | 1094 } else if (v->IsHasCachedArrayIndex()) { |
1095 } else if (v->IsHasInstanceType()) { | 1095 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v); |
1096 HHasInstanceType* compare = HHasInstanceType::cast(v); | 1096 ASSERT(compare->value()->representation().IsTagged()); |
1097 ASSERT(compare->value()->representation().IsTagged()); | 1097 return new LHasCachedArrayIndexAndBranch( |
1098 | 1098 UseRegisterAtStart(compare->value())); |
1099 return new LHasInstanceTypeAndBranch( | 1099 } else if (v->IsIsNull()) { |
1100 UseRegisterAtStart(compare->value())); | 1100 HIsNull* compare = HIsNull::cast(v); |
1101 } else if (v->IsHasCachedArrayIndex()) { | 1101 ASSERT(compare->value()->representation().IsTagged()); |
1102 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v); | 1102 // We only need a temp register for non-strict compare. |
1103 ASSERT(compare->value()->representation().IsTagged()); | 1103 LOperand* temp = compare->is_strict() ? NULL : TempRegister(); |
1104 | 1104 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), temp); |
1105 return new LHasCachedArrayIndexAndBranch( | 1105 } else if (v->IsIsObject()) { |
1106 UseRegisterAtStart(compare->value())); | 1106 HIsObject* compare = HIsObject::cast(v); |
1107 } else if (v->IsIsNull()) { | 1107 ASSERT(compare->value()->representation().IsTagged()); |
1108 HIsNull* compare = HIsNull::cast(v); | 1108 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value())); |
1109 ASSERT(compare->value()->representation().IsTagged()); | 1109 } else if (v->IsCompareJSObjectEq()) { |
1110 | 1110 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); |
1111 // We only need a temp register for non-strict compare. | 1111 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), |
1112 LOperand* temp = compare->is_strict() ? NULL : TempRegister(); | |
1113 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), | |
1114 temp); | |
1115 } else if (v->IsIsObject()) { | |
1116 HIsObject* compare = HIsObject::cast(v); | |
1117 ASSERT(compare->value()->representation().IsTagged()); | |
1118 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value())); | |
1119 } else if (v->IsCompareJSObjectEq()) { | |
1120 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); | |
1121 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), | |
1122 UseRegisterAtStart(compare->right())); | |
1123 } else if (v->IsCompareSymbolEq()) { | |
1124 HCompareSymbolEq* compare = HCompareSymbolEq::cast(v); | |
1125 return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()), | |
1126 UseRegisterAtStart(compare->right())); | 1112 UseRegisterAtStart(compare->right())); |
1127 } else if (v->IsInstanceOf()) { | 1113 } else if (v->IsCompareSymbolEq()) { |
1128 HInstanceOf* instance_of = HInstanceOf::cast(v); | 1114 HCompareSymbolEq* compare = HCompareSymbolEq::cast(v); |
1129 LInstanceOfAndBranch* result = | 1115 return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()), |
1130 new LInstanceOfAndBranch(UseFixed(instance_of->left(), rax), | 1116 UseRegisterAtStart(compare->right())); |
1131 UseFixed(instance_of->right(), rdx)); | 1117 } else if (v->IsInstanceOf()) { |
1132 return MarkAsCall(result, instr); | 1118 HInstanceOf* instance_of = HInstanceOf::cast(v); |
1133 } else if (v->IsTypeofIs()) { | 1119 LInstanceOfAndBranch* result = |
1134 HTypeofIs* typeof_is = HTypeofIs::cast(v); | 1120 new LInstanceOfAndBranch(UseFixed(instance_of->left(), rax), |
1135 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value())); | 1121 UseFixed(instance_of->right(), rdx)); |
1136 } else if (v->IsIsConstructCall()) { | 1122 return MarkAsCall(result, instr); |
1137 return new LIsConstructCallAndBranch(TempRegister()); | 1123 } else if (v->IsTypeofIs()) { |
1138 } else { | 1124 HTypeofIs* typeof_is = HTypeofIs::cast(v); |
1139 if (v->IsConstant()) { | 1125 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value())); |
1140 if (HConstant::cast(v)->ToBoolean()) { | 1126 } else if (v->IsIsConstructCall()) { |
1141 return new LGoto(instr->FirstSuccessor()->block_id()); | 1127 return new LIsConstructCallAndBranch(TempRegister()); |
1142 } else { | 1128 } else if (v->IsConstant()) { |
1143 return new LGoto(instr->SecondSuccessor()->block_id()); | 1129 HBasicBlock* successor = HConstant::cast(v)->ToBoolean() |
1144 } | 1130 ? instr->FirstSuccessor() |
1145 } | 1131 : instr->SecondSuccessor(); |
1146 Abort("Undefined compare before branch"); | 1132 return new LGoto(successor->block_id()); |
1147 return NULL; | 1133 } else { |
1148 } | 1134 Abort("Undefined compare before branch"); |
| 1135 return NULL; |
1149 } | 1136 } |
1150 return new LBranch(UseRegisterAtStart(v)); | |
1151 } | 1137 } |
1152 | 1138 |
1153 | 1139 |
1154 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { | 1140 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { |
1155 ASSERT(instr->value()->representation().IsTagged()); | 1141 ASSERT(instr->value()->representation().IsTagged()); |
1156 LOperand* value = UseRegisterAtStart(instr->value()); | 1142 LOperand* value = UseRegisterAtStart(instr->value()); |
1157 return new LCmpMapAndBranch(value); | 1143 return new LCmpMapAndBranch(value); |
1158 } | 1144 } |
1159 | 1145 |
1160 | 1146 |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2206 LOperand* key = UseOrConstantAtStart(instr->key()); | 2192 LOperand* key = UseOrConstantAtStart(instr->key()); |
2207 LOperand* object = UseOrConstantAtStart(instr->object()); | 2193 LOperand* object = UseOrConstantAtStart(instr->object()); |
2208 LIn* result = new LIn(key, object); | 2194 LIn* result = new LIn(key, object); |
2209 return MarkAsCall(DefineFixed(result, rax), instr); | 2195 return MarkAsCall(DefineFixed(result, rax), instr); |
2210 } | 2196 } |
2211 | 2197 |
2212 | 2198 |
2213 } } // namespace v8::internal | 2199 } } // namespace v8::internal |
2214 | 2200 |
2215 #endif // V8_TARGET_ARCH_X64 | 2201 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |