Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: src/arm/lithium-arm.cc

Issue 10190007: Revert r11420 because Win32 compilation was broken. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/lithium-arm.h ('k') | src/arm/lithium-codegen-arm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 LOperand* dividend = UseFixed(instr->left(), r0); 1308 LOperand* dividend = UseFixed(instr->left(), r0);
1309 LOperand* divisor = UseFixed(instr->right(), r1); 1309 LOperand* divisor = UseFixed(instr->right(), r1);
1310 return AssignEnvironment(AssignPointerMap( 1310 return AssignEnvironment(AssignPointerMap(
1311 DefineFixed(new(zone()) LDivI(dividend, divisor), r0))); 1311 DefineFixed(new(zone()) LDivI(dividend, divisor), r0)));
1312 } else { 1312 } else {
1313 return DoArithmeticT(Token::DIV, instr); 1313 return DoArithmeticT(Token::DIV, instr);
1314 } 1314 }
1315 } 1315 }
1316 1316
1317 1317
1318 bool LChunkBuilder::HasMagicNumberForDivisor(int32_t divisor) {
1319 uint32_t divisor_abs = abs(divisor);
1320 // Dividing by 0, 1, and powers of 2 is easy.
1321 // Note that IsPowerOf2(0) returns true;
1322 ASSERT(IsPowerOf2(0) == true);
1323 if (IsPowerOf2(divisor_abs)) return true;
1324
1325 // We have magic numbers for a few specific divisors.
1326 // Details and proofs can be found in:
1327 // - Hacker's Delight, Henry S. Warren, Jr.
1328 // - The PowerPC Compiler Writer’s Guide
1329 // and probably many others.
1330 //
1331 // We handle
1332 // <divisor with magic numbers> * <power of 2>
1333 // but not
1334 // <divisor with magic numbers> * <other divisor with magic numbers>
1335 int32_t power_of_2_factor =
1336 CompilerIntrinsics::CountTrailingZeros(divisor_abs);
1337 DivMagicNumbers magic_numbers =
1338 DivMagicNumberFor(divisor_abs >> power_of_2_factor);
1339 if (magic_numbers.M != InvalidDivMagicNumber.M) return true;
1340
1341 return false;
1342 }
1343
1344
1345 HValue* LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(HValue* dividend) {
1346 // A value with an integer representation does not need to be transformed.
1347 if (dividend->representation().IsInteger32()) {
1348 return dividend;
1349 // A change from an integer32 can be replaced by the integer32 value.
1350 } else if (dividend->IsChange() &&
1351 HChange::cast(dividend)->from().IsInteger32()) {
1352 return HChange::cast(dividend)->value();
1353 }
1354 return NULL;
1355 }
1356
1357
1358 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
1359 // Only optimize when we have magic numbers for the divisor.
1360 // The standard integer division routine is usually slower than transitionning
1361 // to VFP.
1362 if (divisor->IsConstant() &&
1363 HConstant::cast(divisor)->HasInteger32Value()) {
1364 HConstant* constant_val = HConstant::cast(divisor);
1365 int32_t int32_val = constant_val->Integer32Value();
1366 if (LChunkBuilder::HasMagicNumberForDivisor(int32_val)) {
1367 return constant_val->CopyToRepresentation(Representation::Integer32());
1368 }
1369 }
1370 return NULL;
1371 }
1372
1373
1374 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1375 HValue* right = instr->right();
1376 LOperand* dividend = UseRegister(instr->left());
1377 LOperand* divisor = UseRegisterOrConstant(right);
1378 LOperand* remainder = TempRegister();
1379 ASSERT(right->IsConstant() &&
1380 HConstant::cast(right)->HasInteger32Value() &&
1381 HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value()));
1382 return AssignEnvironment(DefineAsRegister(
1383 new LMathFloorOfDiv(dividend, divisor, remainder)));
1384 }
1385
1386
1387 LInstruction* LChunkBuilder::DoMod(HMod* instr) { 1318 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1388 if (instr->representation().IsInteger32()) { 1319 if (instr->representation().IsInteger32()) {
1389 ASSERT(instr->left()->representation().IsInteger32()); 1320 ASSERT(instr->left()->representation().IsInteger32());
1390 ASSERT(instr->right()->representation().IsInteger32()); 1321 ASSERT(instr->right()->representation().IsInteger32());
1391 1322
1392 LModI* mod; 1323 LModI* mod;
1393 if (instr->HasPowerOf2Divisor()) { 1324 if (instr->HasPowerOf2Divisor()) {
1394 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); 1325 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero));
1395 LOperand* value = UseRegisterAtStart(instr->left()); 1326 LOperand* value = UseRegisterAtStart(instr->left());
1396 mod = new(zone()) LModI(value, UseOrConstant(instr->right())); 1327 mod = new(zone()) LModI(value, UseOrConstant(instr->right()));
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 2325
2395 2326
2396 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2327 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2397 LOperand* object = UseRegister(instr->object()); 2328 LOperand* object = UseRegister(instr->object());
2398 LOperand* index = UseRegister(instr->index()); 2329 LOperand* index = UseRegister(instr->index());
2399 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); 2330 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index));
2400 } 2331 }
2401 2332
2402 2333
2403 } } // namespace v8::internal 2334 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.h ('k') | src/arm/lithium-codegen-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698