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 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1221 } | 1221 } |
1222 | 1222 |
1223 | 1223 |
1224 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { | 1224 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
1225 if (divisor->IsConstant() && | 1225 if (divisor->IsConstant() && |
1226 HConstant::cast(divisor)->HasInteger32Value()) { | 1226 HConstant::cast(divisor)->HasInteger32Value()) { |
1227 HConstant* constant_val = HConstant::cast(divisor); | 1227 HConstant* constant_val = HConstant::cast(divisor); |
1228 return constant_val->CopyToRepresentation(Representation::Integer32(), | 1228 return constant_val->CopyToRepresentation(Representation::Integer32(), |
1229 divisor->block()->zone()); | 1229 divisor->block()->zone()); |
1230 } | 1230 } |
1231 // A value with an integer representation does not need to be transformed. | |
1232 if (divisor->representation().IsInteger32()) | |
1233 return divisor; | |
1234 // A change from an integer32 can be replaced by the integer32 value. | |
1235 else if (divisor->IsChange() && | |
1236 HChange::cast(divisor)->from().IsInteger32()) | |
Yang
2012/12/27 14:41:53
Please indent the second line of the if-condition
| |
1237 return HChange::cast(divisor)->value(); | |
1231 return NULL; | 1238 return NULL; |
1232 } | 1239 } |
1233 | 1240 |
1234 | 1241 |
1235 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1242 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
1236 HValue* right = instr->right(); | 1243 HValue* right = instr->right(); |
1244 if (!right->IsConstant()) { | |
1245 ASSERT(right->representation().IsInteger32()); | |
1246 // The temporary operand is necessary to ensure that right is not allocated | |
1247 // into rdx. | |
1248 LOperand* temp = FixedTemp(rdx); | |
1249 LOperand* dividend = UseFixed(instr->left(), rax); | |
1250 LOperand* divisor = UseRegister(instr->right()); | |
1251 LDivI* flooring_div = new(zone()) LDivI(dividend, divisor, temp); | |
1252 return AssignEnvironment(DefineFixed(flooring_div, rax)); | |
1253 } | |
1254 | |
1237 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value()); | 1255 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value()); |
1238 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right)); | 1256 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right)); |
1239 int32_t divisor_si = HConstant::cast(right)->Integer32Value(); | 1257 int32_t divisor_si = HConstant::cast(right)->Integer32Value(); |
1240 if (divisor_si == 0) { | 1258 if (divisor_si == 0) { |
1241 LOperand* dividend = UseRegister(instr->left()); | 1259 LOperand* dividend = UseRegister(instr->left()); |
1242 return AssignEnvironment(DefineAsRegister( | 1260 return AssignEnvironment(DefineAsRegister( |
1243 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL))); | 1261 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL))); |
1244 } else if (IsPowerOf2(abs(divisor_si))) { | 1262 } else if (IsPowerOf2(abs(divisor_si))) { |
1245 LOperand* dividend = UseRegisterAtStart(instr->left()); | 1263 LOperand* dividend = UseRegisterAtStart(instr->left()); |
1246 LInstruction* result = DefineAsRegister( | 1264 LInstruction* result = DefineAsRegister( |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2327 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2345 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2328 LOperand* object = UseRegister(instr->object()); | 2346 LOperand* object = UseRegister(instr->object()); |
2329 LOperand* index = UseTempRegister(instr->index()); | 2347 LOperand* index = UseTempRegister(instr->index()); |
2330 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2348 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2331 } | 2349 } |
2332 | 2350 |
2333 | 2351 |
2334 } } // namespace v8::internal | 2352 } } // namespace v8::internal |
2335 | 2353 |
2336 #endif // V8_TARGET_ARCH_X64 | 2354 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |