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 TempRegister()); | 1056 TempRegister()); |
1057 } else if (v->IsCompare()) { | 1057 } else if (v->IsCompare()) { |
1058 HCompare* compare = HCompare::cast(v); | 1058 HCompare* compare = HCompare::cast(v); |
1059 Token::Value op = compare->token(); | 1059 Token::Value op = compare->token(); |
1060 HValue* left = compare->left(); | 1060 HValue* left = compare->left(); |
1061 HValue* right = compare->right(); | 1061 HValue* right = compare->right(); |
1062 Representation r = compare->GetInputRepresentation(); | 1062 Representation r = compare->GetInputRepresentation(); |
1063 if (r.IsInteger32()) { | 1063 if (r.IsInteger32()) { |
1064 ASSERT(left->representation().IsInteger32()); | 1064 ASSERT(left->representation().IsInteger32()); |
1065 ASSERT(right->representation().IsInteger32()); | 1065 ASSERT(right->representation().IsInteger32()); |
1066 | 1066 return new LCmpIDAndBranch(UseRegisterAtStart(left), |
1067 return new LCmpIDAndBranch(UseRegisterAtStart(left), | 1067 UseOrConstantAtStart(right)); |
1068 UseOrConstantAtStart(right)); | 1068 } else if (r.IsDouble()) { |
1069 } else if (r.IsDouble()) { | 1069 ASSERT(left->representation().IsDouble()); |
1070 ASSERT(left->representation().IsDouble()); | 1070 ASSERT(right->representation().IsDouble()); |
1071 ASSERT(right->representation().IsDouble()); | 1071 return new LCmpIDAndBranch(UseRegisterAtStart(left), |
1072 | 1072 UseRegisterAtStart(right)); |
1073 return new LCmpIDAndBranch(UseRegisterAtStart(left), | 1073 } else { |
1074 UseRegisterAtStart(right)); | 1074 ASSERT(left->representation().IsTagged()); |
1075 } else { | 1075 ASSERT(right->representation().IsTagged()); |
1076 ASSERT(left->representation().IsTagged()); | 1076 bool reversed = op == Token::GT || op == Token::LTE; |
1077 ASSERT(right->representation().IsTagged()); | 1077 LOperand* left_operand = UseFixed(left, reversed ? eax : edx); |
1078 bool reversed = op == Token::GT || op == Token::LTE; | 1078 LOperand* right_operand = UseFixed(right, reversed ? edx : eax); |
1079 LOperand* left_operand = UseFixed(left, reversed ? eax : edx); | 1079 LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, right_operand); |
1080 LOperand* right_operand = UseFixed(right, reversed ? edx : eax); | 1080 return MarkAsCall(result, instr); |
1081 LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, | 1081 } |
1082 right_operand); | 1082 } else if (v->IsIsSmi()) { |
1083 return MarkAsCall(result, instr); | 1083 HIsSmi* compare = HIsSmi::cast(v); |
1084 } | 1084 ASSERT(compare->value()->representation().IsTagged()); |
1085 } else if (v->IsIsSmi()) { | 1085 return new LIsSmiAndBranch(Use(compare->value())); |
1086 HIsSmi* compare = HIsSmi::cast(v); | 1086 } else if (v->IsIsUndetectable()) { |
1087 ASSERT(compare->value()->representation().IsTagged()); | 1087 HIsUndetectable* compare = HIsUndetectable::cast(v); |
1088 | 1088 ASSERT(compare->value()->representation().IsTagged()); |
1089 return new LIsSmiAndBranch(Use(compare->value())); | 1089 return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()), |
1090 } else if (v->IsIsUndetectable()) { | 1090 TempRegister()); |
1091 HIsUndetectable* compare = HIsUndetectable::cast(v); | 1091 } else if (v->IsHasInstanceType()) { |
1092 ASSERT(compare->value()->representation().IsTagged()); | 1092 HHasInstanceType* compare = HHasInstanceType::cast(v); |
1093 | 1093 ASSERT(compare->value()->representation().IsTagged()); |
1094 return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()), | 1094 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()), |
1095 TempRegister()); | 1095 TempRegister()); |
1096 } else if (v->IsHasInstanceType()) { | 1096 } else if (v->IsHasCachedArrayIndex()) { |
1097 HHasInstanceType* compare = HHasInstanceType::cast(v); | 1097 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v); |
1098 ASSERT(compare->value()->representation().IsTagged()); | 1098 ASSERT(compare->value()->representation().IsTagged()); |
1099 | 1099 return new LHasCachedArrayIndexAndBranch( |
1100 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()), | 1100 UseRegisterAtStart(compare->value())); |
1101 TempRegister()); | 1101 } else if (v->IsIsNull()) { |
1102 } else if (v->IsHasCachedArrayIndex()) { | 1102 HIsNull* compare = HIsNull::cast(v); |
1103 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v); | 1103 ASSERT(compare->value()->representation().IsTagged()); |
1104 ASSERT(compare->value()->representation().IsTagged()); | 1104 // We only need a temp register for non-strict compare. |
1105 | 1105 LOperand* temp = compare->is_strict() ? NULL : TempRegister(); |
1106 return new LHasCachedArrayIndexAndBranch( | 1106 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), temp); |
1107 UseRegisterAtStart(compare->value())); | 1107 } else if (v->IsIsObject()) { |
1108 } else if (v->IsIsNull()) { | 1108 HIsObject* compare = HIsObject::cast(v); |
1109 HIsNull* compare = HIsNull::cast(v); | 1109 ASSERT(compare->value()->representation().IsTagged()); |
1110 ASSERT(compare->value()->representation().IsTagged()); | 1110 LOperand* temp1 = TempRegister(); |
1111 | 1111 LOperand* temp2 = TempRegister(); |
1112 // We only need a temp register for non-strict compare. | 1112 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), |
1113 LOperand* temp = compare->is_strict() ? NULL : TempRegister(); | 1113 temp1, |
1114 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), | 1114 temp2); |
1115 temp); | 1115 } else if (v->IsCompareJSObjectEq()) { |
1116 } else if (v->IsIsObject()) { | 1116 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); |
1117 HIsObject* compare = HIsObject::cast(v); | 1117 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), |
1118 ASSERT(compare->value()->representation().IsTagged()); | |
1119 | |
1120 LOperand* temp1 = TempRegister(); | |
1121 LOperand* temp2 = TempRegister(); | |
1122 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), | |
1123 temp1, | |
1124 temp2); | |
1125 } else if (v->IsCompareJSObjectEq()) { | |
1126 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); | |
1127 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), | |
1128 UseRegisterAtStart(compare->right())); | |
1129 } else if (v->IsCompareSymbolEq()) { | |
1130 HCompareSymbolEq* compare = HCompareSymbolEq::cast(v); | |
1131 return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()), | |
1132 UseRegisterAtStart(compare->right())); | 1118 UseRegisterAtStart(compare->right())); |
1133 } else if (v->IsInstanceOf()) { | 1119 } else if (v->IsCompareSymbolEq()) { |
1134 HInstanceOf* instance_of = HInstanceOf::cast(v); | 1120 HCompareSymbolEq* compare = HCompareSymbolEq::cast(v); |
1135 LOperand* left = UseFixed(instance_of->left(), InstanceofStub::left()); | 1121 return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()), |
1136 LOperand* right = UseFixed(instance_of->right(), InstanceofStub::right()); | 1122 UseRegisterAtStart(compare->right())); |
1137 LOperand* context = UseFixed(instance_of->context(), esi); | 1123 } else if (v->IsInstanceOf()) { |
1138 LInstanceOfAndBranch* result = | 1124 HInstanceOf* instance_of = HInstanceOf::cast(v); |
1139 new LInstanceOfAndBranch(context, left, right); | 1125 LOperand* left = UseFixed(instance_of->left(), InstanceofStub::left()); |
1140 return MarkAsCall(result, instr); | 1126 LOperand* right = UseFixed(instance_of->right(), InstanceofStub::right()); |
1141 } else if (v->IsTypeofIs()) { | 1127 LOperand* context = UseFixed(instance_of->context(), esi); |
1142 HTypeofIs* typeof_is = HTypeofIs::cast(v); | 1128 LInstanceOfAndBranch* result = |
1143 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value())); | 1129 new LInstanceOfAndBranch(context, left, right); |
1144 } else if (v->IsIsConstructCall()) { | 1130 return MarkAsCall(result, instr); |
1145 return new LIsConstructCallAndBranch(TempRegister()); | 1131 } else if (v->IsTypeofIs()) { |
1146 } else { | 1132 HTypeofIs* typeof_is = HTypeofIs::cast(v); |
1147 if (v->IsConstant()) { | 1133 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value())); |
1148 if (HConstant::cast(v)->ToBoolean()) { | 1134 } else if (v->IsIsConstructCall()) { |
1149 return new LGoto(instr->FirstSuccessor()->block_id()); | 1135 return new LIsConstructCallAndBranch(TempRegister()); |
1150 } else { | 1136 } else if (v->IsConstant()) { |
1151 return new LGoto(instr->SecondSuccessor()->block_id()); | 1137 HBasicBlock* successor = HConstant::cast(v)->ToBoolean() |
1152 } | 1138 ? instr->FirstSuccessor() |
1153 } | 1139 : instr->SecondSuccessor(); |
1154 Abort("Undefined compare before branch"); | 1140 return new LGoto(successor->block_id()); |
1155 return NULL; | 1141 } else { |
1156 } | 1142 Abort("Undefined compare before branch"); |
| 1143 return NULL; |
1157 } | 1144 } |
1158 return new LBranch(UseRegisterAtStart(v)); | |
1159 } | 1145 } |
1160 | 1146 |
1161 | 1147 |
1162 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { | 1148 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { |
1163 ASSERT(instr->value()->representation().IsTagged()); | 1149 ASSERT(instr->value()->representation().IsTagged()); |
1164 LOperand* value = UseRegisterAtStart(instr->value()); | 1150 LOperand* value = UseRegisterAtStart(instr->value()); |
1165 return new LCmpMapAndBranch(value); | 1151 return new LCmpMapAndBranch(value); |
1166 } | 1152 } |
1167 | 1153 |
1168 | 1154 |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2264 LOperand* key = UseOrConstantAtStart(instr->key()); | 2250 LOperand* key = UseOrConstantAtStart(instr->key()); |
2265 LOperand* object = UseOrConstantAtStart(instr->object()); | 2251 LOperand* object = UseOrConstantAtStart(instr->object()); |
2266 LIn* result = new LIn(key, object); | 2252 LIn* result = new LIn(key, object); |
2267 return MarkAsCall(DefineFixed(result, eax), instr); | 2253 return MarkAsCall(DefineFixed(result, eax), instr); |
2268 } | 2254 } |
2269 | 2255 |
2270 | 2256 |
2271 } } // namespace v8::internal | 2257 } } // namespace v8::internal |
2272 | 2258 |
2273 #endif // V8_TARGET_ARCH_IA32 | 2259 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |