OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1203 // A change from an integer32 can be replaced by the integer32 value. | 1203 // A change from an integer32 can be replaced by the integer32 value. |
1204 } else if (dividend->IsChange() && | 1204 } else if (dividend->IsChange() && |
1205 HChange::cast(dividend)->from().IsInteger32()) { | 1205 HChange::cast(dividend)->from().IsInteger32()) { |
1206 return HChange::cast(dividend)->value(); | 1206 return HChange::cast(dividend)->value(); |
1207 } | 1207 } |
1208 return NULL; | 1208 return NULL; |
1209 } | 1209 } |
1210 | 1210 |
1211 | 1211 |
1212 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { | 1212 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
1213 // Only optimize when we have magic numbers for the divisor. | 1213 if (CpuFeatures::IsSupported(SUDIV)) { |
1214 // The standard integer division routine is usually slower than transitionning | 1214 // A value with an integer representation does not need to be transformed. |
1215 // to VFP. | 1215 if (divisor->representation().IsInteger32()) { |
1216 if (divisor->IsConstant() && | 1216 return divisor; |
1217 HConstant::cast(divisor)->HasInteger32Value()) { | 1217 // A change from an integer32 can be replaced by the integer32 value. |
1218 HConstant* constant_val = HConstant::cast(divisor); | 1218 } else if (divisor->IsChange() && |
1219 int32_t int32_val = constant_val->Integer32Value(); | 1219 HChange::cast(divisor)->from().IsInteger32()) { |
1220 if (LChunkBuilder::HasMagicNumberForDivisor(int32_val)) { | 1220 return HChange::cast(divisor)->value(); |
1221 } else if (divisor->IsConstant() && | |
1222 HConstant::cast(divisor)->HasInteger32Value()) { | |
1223 HConstant* constant_val = HConstant::cast(divisor); | |
1221 return constant_val->CopyToRepresentation(Representation::Integer32(), | 1224 return constant_val->CopyToRepresentation(Representation::Integer32(), |
1222 divisor->block()->zone()); | 1225 divisor->block()->zone()); |
1223 } | 1226 } |
1227 } else { | |
1228 // Only optimize when we have magic numbers for the divisor. | |
1229 // The standard integer division routine is usually slower than | |
1230 // transitionning to VFP. | |
1231 if (divisor->IsConstant() && | |
1232 HConstant::cast(divisor)->HasInteger32Value()) { | |
1233 HConstant* constant_val = HConstant::cast(divisor); | |
1234 int32_t int32_val = constant_val->Integer32Value(); | |
1235 if (LChunkBuilder::HasMagicNumberForDivisor(int32_val)) { | |
1236 return constant_val->CopyToRepresentation(Representation::Integer32(), | |
danno
2012/11/22 11:37:59
Is it possible to not duplicate the very similar c
| |
1237 divisor->block()->zone()); | |
1238 } | |
1239 } | |
1224 } | 1240 } |
1225 return NULL; | 1241 return NULL; |
1226 } | 1242 } |
1227 | 1243 |
1228 | 1244 |
1229 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1245 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
1230 HValue* right = instr->right(); | 1246 HValue* right = instr->right(); |
1231 LOperand* dividend = UseRegister(instr->left()); | 1247 LOperand* dividend = UseRegister(instr->left()); |
1232 LOperand* divisor = UseRegisterOrConstant(right); | 1248 LOperand* divisor = UseRegisterOrConstant(right); |
1233 LOperand* remainder = TempRegister(); | 1249 LOperand* remainder = TempRegister(); |
1234 ASSERT(right->IsConstant() && | 1250 ASSERT(CpuFeatures::IsSupported(SUDIV) || |
1235 HConstant::cast(right)->HasInteger32Value() && | 1251 (right->IsConstant() && |
1236 HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value())); | 1252 HConstant::cast(right)->HasInteger32Value() && |
1237 return AssignEnvironment(DefineAsRegister( | 1253 HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value()))); |
1254 return AssignEnvironment(DefineAsRegister( | |
1238 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder))); | 1255 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder))); |
1239 } | 1256 } |
1240 | 1257 |
1241 | 1258 |
1242 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1259 LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
1243 if (instr->representation().IsInteger32()) { | 1260 if (instr->representation().IsInteger32()) { |
1244 ASSERT(instr->left()->representation().IsInteger32()); | 1261 ASSERT(instr->left()->representation().IsInteger32()); |
1245 ASSERT(instr->right()->representation().IsInteger32()); | 1262 ASSERT(instr->right()->representation().IsInteger32()); |
1246 | 1263 |
1247 LModI* mod; | 1264 LModI* mod; |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2300 | 2317 |
2301 | 2318 |
2302 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2319 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2303 LOperand* object = UseRegister(instr->object()); | 2320 LOperand* object = UseRegister(instr->object()); |
2304 LOperand* index = UseRegister(instr->index()); | 2321 LOperand* index = UseRegister(instr->index()); |
2305 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2322 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2306 } | 2323 } |
2307 | 2324 |
2308 | 2325 |
2309 } } // namespace v8::internal | 2326 } } // namespace v8::internal |
OLD | NEW |