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 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1234 // A change from an integer32 can be replaced by the integer32 value. | 1234 // A change from an integer32 can be replaced by the integer32 value. |
1235 } else if (dividend->IsChange() && | 1235 } else if (dividend->IsChange() && |
1236 HChange::cast(dividend)->from().IsInteger32()) { | 1236 HChange::cast(dividend)->from().IsInteger32()) { |
1237 return HChange::cast(dividend)->value(); | 1237 return HChange::cast(dividend)->value(); |
1238 } | 1238 } |
1239 return NULL; | 1239 return NULL; |
1240 } | 1240 } |
1241 | 1241 |
1242 | 1242 |
1243 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { | 1243 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
1244 // Only optimize when we have magic numbers for the divisor. | 1244 if (CpuFeatures::IsSupported(SUDIV)) { |
1245 // The standard integer division routine is usually slower than transitionning | 1245 // A value with an integer representation does not need to be transformed. |
1246 // to VFP. | 1246 if (divisor->representation().IsInteger32()) { |
1247 if (divisor->IsConstant() && | 1247 return divisor; |
1248 HConstant::cast(divisor)->HasInteger32Value()) { | 1248 // A change from an integer32 can be replaced by the integer32 value. |
1249 } else if (divisor->IsChange() && | |
1250 HChange::cast(divisor)->from().IsInteger32()) { | |
1251 return HChange::cast(divisor)->value(); | |
1252 } | |
1253 } | |
1254 | |
1255 if (divisor->IsConstant() && HConstant::cast(divisor)->HasInteger32Value()) { | |
1249 HConstant* constant_val = HConstant::cast(divisor); | 1256 HConstant* constant_val = HConstant::cast(divisor); |
1250 int32_t int32_val = constant_val->Integer32Value(); | 1257 int32_t int32_val = constant_val->Integer32Value(); |
1251 if (LChunkBuilder::HasMagicNumberForDivisor(int32_val)) { | 1258 if (LChunkBuilder::HasMagicNumberForDivisor(int32_val) || |
1259 CpuFeatures::IsSupported(SUDIV)) { | |
1252 return constant_val->CopyToRepresentation(Representation::Integer32(), | 1260 return constant_val->CopyToRepresentation(Representation::Integer32(), |
1253 divisor->block()->zone()); | 1261 divisor->block()->zone()); |
1254 } | 1262 } |
1255 } | 1263 } |
1264 | |
1256 return NULL; | 1265 return NULL; |
1257 } | 1266 } |
1258 | 1267 |
1259 | 1268 |
1260 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1269 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
1261 HValue* right = instr->right(); | 1270 HValue* right = instr->right(); |
1262 LOperand* dividend = UseRegister(instr->left()); | 1271 LOperand* dividend = UseRegister(instr->left()); |
1263 LOperand* divisor = UseRegisterOrConstant(right); | 1272 LOperand* divisor = CpuFeatures::IsSupported(SUDIV) ? UseRegister(right) |
danno
2012/12/20 16:25:38
nit: indentation. For 80+col conditional operator
| |
1264 LOperand* remainder = TempRegister(); | 1273 : UseOrConstant(right); |
1265 ASSERT(right->IsConstant() && | 1274 LOperand* remainder = TempRegister(); |
1266 HConstant::cast(right)->HasInteger32Value() && | 1275 ASSERT(CpuFeatures::IsSupported(SUDIV) || |
1267 HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value())); | 1276 (right->IsConstant() && |
1268 return AssignEnvironment(DefineAsRegister( | 1277 HConstant::cast(right)->HasInteger32Value() && |
1278 HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value()))); | |
1279 return AssignEnvironment(DefineAsRegister( | |
1269 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder))); | 1280 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder))); |
1270 } | 1281 } |
1271 | 1282 |
1272 | 1283 |
1273 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1284 LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
1274 if (instr->representation().IsInteger32()) { | 1285 if (instr->representation().IsInteger32()) { |
1275 ASSERT(instr->left()->representation().IsInteger32()); | 1286 ASSERT(instr->left()->representation().IsInteger32()); |
1276 ASSERT(instr->right()->representation().IsInteger32()); | 1287 ASSERT(instr->right()->representation().IsInteger32()); |
1277 | 1288 |
1278 LModI* mod; | 1289 LModI* mod; |
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2387 | 2398 |
2388 | 2399 |
2389 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2400 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2390 LOperand* object = UseRegister(instr->object()); | 2401 LOperand* object = UseRegister(instr->object()); |
2391 LOperand* index = UseRegister(instr->index()); | 2402 LOperand* index = UseRegister(instr->index()); |
2392 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2403 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2393 } | 2404 } |
2394 | 2405 |
2395 | 2406 |
2396 } } // namespace v8::internal | 2407 } } // namespace v8::internal |
OLD | NEW |