| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 int vreg = allocator_->GetVirtualRegister(); | 646 int vreg = allocator_->GetVirtualRegister(); |
| 647 if (!allocator_->AllocationOk()) { | 647 if (!allocator_->AllocationOk()) { |
| 648 Abort("Out of virtual registers while trying to allocate temp register."); | 648 Abort("Out of virtual registers while trying to allocate temp register."); |
| 649 vreg = 0; | 649 vreg = 0; |
| 650 } | 650 } |
| 651 operand->set_virtual_register(vreg); | 651 operand->set_virtual_register(vreg); |
| 652 return operand; | 652 return operand; |
| 653 } | 653 } |
| 654 | 654 |
| 655 | 655 |
| 656 LUnallocated* LChunkBuilder::TempDoubleRegister() { |
| 657 LUnallocated* operand = |
| 658 new(zone()) LUnallocated(LUnallocated::TEMP_DOUBLE_REGISTER); |
| 659 int vreg = allocator_->GetVirtualRegister(); |
| 660 if (!allocator_->AllocationOk()) { |
| 661 Abort("Out of virtual registers while trying to allocate temp register."); |
| 662 vreg = 0; |
| 663 } |
| 664 operand->set_virtual_register(vreg); |
| 665 return operand; |
| 666 } |
| 667 |
| 668 |
| 656 LOperand* LChunkBuilder::FixedTemp(Register reg) { | 669 LOperand* LChunkBuilder::FixedTemp(Register reg) { |
| 657 LUnallocated* operand = ToUnallocated(reg); | 670 LUnallocated* operand = ToUnallocated(reg); |
| 658 ASSERT(operand->HasFixedPolicy()); | 671 ASSERT(operand->HasFixedPolicy()); |
| 659 return operand; | 672 return operand; |
| 660 } | 673 } |
| 661 | 674 |
| 662 | 675 |
| 663 LOperand* LChunkBuilder::FixedTemp(DoubleRegister reg) { | 676 LOperand* LChunkBuilder::FixedTemp(DoubleRegister reg) { |
| 664 LUnallocated* operand = ToUnallocated(reg); | 677 LUnallocated* operand = ToUnallocated(reg); |
| 665 ASSERT(operand->HasFixedPolicy()); | 678 ASSERT(operand->HasFixedPolicy()); |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 | 1161 |
| 1149 LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) { | 1162 LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) { |
| 1150 LOperand* input = UseRegister(instr->value()); | 1163 LOperand* input = UseRegister(instr->value()); |
| 1151 LMathFloor* result = new(zone()) LMathFloor(input); | 1164 LMathFloor* result = new(zone()) LMathFloor(input); |
| 1152 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); | 1165 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); |
| 1153 } | 1166 } |
| 1154 | 1167 |
| 1155 | 1168 |
| 1156 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) { | 1169 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) { |
| 1157 LOperand* input = UseRegister(instr->value()); | 1170 LOperand* input = UseRegister(instr->value()); |
| 1158 LOperand* temp = FixedTemp(d3); | 1171 LOperand* temp = TempDoubleRegister(); |
| 1159 LMathRound* result = new(zone()) LMathRound(input, temp); | 1172 LMathRound* result = new(zone()) LMathRound(input, temp); |
| 1160 return AssignEnvironment(DefineAsRegister(result)); | 1173 return AssignEnvironment(DefineAsRegister(result)); |
| 1161 } | 1174 } |
| 1162 | 1175 |
| 1163 | 1176 |
| 1164 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { | 1177 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { |
| 1165 LOperand* input = UseRegister(instr->value()); | 1178 LOperand* input = UseRegister(instr->value()); |
| 1166 LMathAbs* result = new(zone()) LMathAbs(input); | 1179 LMathAbs* result = new(zone()) LMathAbs(input); |
| 1167 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); | 1180 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); |
| 1168 } | 1181 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1195 return MarkAsCall(DefineFixedDouble(result, d2), instr); | 1208 return MarkAsCall(DefineFixedDouble(result, d2), instr); |
| 1196 } | 1209 } |
| 1197 | 1210 |
| 1198 | 1211 |
| 1199 LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { | 1212 LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { |
| 1200 ASSERT(instr->representation().IsDouble()); | 1213 ASSERT(instr->representation().IsDouble()); |
| 1201 ASSERT(instr->value()->representation().IsDouble()); | 1214 ASSERT(instr->value()->representation().IsDouble()); |
| 1202 LOperand* input = UseTempRegister(instr->value()); | 1215 LOperand* input = UseTempRegister(instr->value()); |
| 1203 LOperand* temp1 = TempRegister(); | 1216 LOperand* temp1 = TempRegister(); |
| 1204 LOperand* temp2 = TempRegister(); | 1217 LOperand* temp2 = TempRegister(); |
| 1205 LOperand* double_temp = FixedTemp(d3); // Chosen by fair dice roll. | 1218 LOperand* double_temp = TempDoubleRegister(); |
| 1206 LMathExp* result = new(zone()) LMathExp(input, double_temp, temp1, temp2); | 1219 LMathExp* result = new(zone()) LMathExp(input, double_temp, temp1, temp2); |
| 1207 return DefineAsRegister(result); | 1220 return DefineAsRegister(result); |
| 1208 } | 1221 } |
| 1209 | 1222 |
| 1210 | 1223 |
| 1211 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) { | 1224 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) { |
| 1212 LOperand* input = UseRegister(instr->value()); | 1225 LOperand* input = UseRegister(instr->value()); |
| 1213 LMathSqrt* result = new(zone()) LMathSqrt(input); | 1226 LMathSqrt* result = new(zone()) LMathSqrt(input); |
| 1214 return DefineAsRegister(result); | 1227 return DefineAsRegister(result); |
| 1215 } | 1228 } |
| 1216 | 1229 |
| 1217 | 1230 |
| 1218 LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) { | 1231 LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) { |
| 1219 LOperand* input = UseFixedDouble(instr->value(), d2); | 1232 LOperand* input = UseFixedDouble(instr->value(), d2); |
| 1220 LOperand* temp = FixedTemp(d3); | 1233 LOperand* temp = TempDoubleRegister(); |
| 1221 LMathPowHalf* result = new(zone()) LMathPowHalf(input, temp); | 1234 LMathPowHalf* result = new(zone()) LMathPowHalf(input, temp); |
| 1222 return DefineFixedDouble(result, d2); | 1235 return DefineFixedDouble(result, d2); |
| 1223 } | 1236 } |
| 1224 | 1237 |
| 1225 | 1238 |
| 1226 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { | 1239 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { |
| 1227 ASSERT(instr->key()->representation().IsTagged()); | 1240 ASSERT(instr->key()->representation().IsTagged()); |
| 1228 argument_count_ -= instr->argument_count(); | 1241 argument_count_ -= instr->argument_count(); |
| 1229 LOperand* key = UseFixed(instr->key(), r2); | 1242 LOperand* key = UseFixed(instr->key(), r2); |
| 1230 return MarkAsCall(DefineFixed(new(zone()) LCallKeyed(key), r0), instr); | 1243 return MarkAsCall(DefineFixed(new(zone()) LCallKeyed(key), r0), instr); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 } else if (instr->representation().IsInteger32()) { | 1348 } else if (instr->representation().IsInteger32()) { |
| 1336 if (instr->HasPowerOf2Divisor()) { | 1349 if (instr->HasPowerOf2Divisor()) { |
| 1337 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); | 1350 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); |
| 1338 LOperand* value = UseRegisterAtStart(instr->left()); | 1351 LOperand* value = UseRegisterAtStart(instr->left()); |
| 1339 LDivI* div = | 1352 LDivI* div = |
| 1340 new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL); | 1353 new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL); |
| 1341 return AssignEnvironment(DefineSameAsFirst(div)); | 1354 return AssignEnvironment(DefineSameAsFirst(div)); |
| 1342 } | 1355 } |
| 1343 LOperand* dividend = UseRegister(instr->left()); | 1356 LOperand* dividend = UseRegister(instr->left()); |
| 1344 LOperand* divisor = UseRegister(instr->right()); | 1357 LOperand* divisor = UseRegister(instr->right()); |
| 1345 LOperand* temp = CpuFeatures::IsSupported(SUDIV) ? NULL : FixedTemp(d4); | 1358 LOperand* temp = |
| 1359 CpuFeatures::IsSupported(SUDIV) ? NULL : TempDoubleRegister(); |
| 1346 LDivI* div = new(zone()) LDivI(dividend, divisor, temp); | 1360 LDivI* div = new(zone()) LDivI(dividend, divisor, temp); |
| 1347 return AssignEnvironment(DefineAsRegister(div)); | 1361 return AssignEnvironment(DefineAsRegister(div)); |
| 1348 } else { | 1362 } else { |
| 1349 return DoArithmeticT(Token::DIV, instr); | 1363 return DoArithmeticT(Token::DIV, instr); |
| 1350 } | 1364 } |
| 1351 } | 1365 } |
| 1352 | 1366 |
| 1353 | 1367 |
| 1354 bool LChunkBuilder::HasMagicNumberForDivisor(int32_t divisor) { | 1368 bool LChunkBuilder::HasMagicNumberForDivisor(int32_t divisor) { |
| 1355 uint32_t divisor_abs = abs(divisor); | 1369 uint32_t divisor_abs = abs(divisor); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 right->RangeCanInclude(-1) && | 1462 right->RangeCanInclude(-1) && |
| 1449 instr->CheckFlag(HValue::kBailoutOnMinusZero)) || | 1463 instr->CheckFlag(HValue::kBailoutOnMinusZero)) || |
| 1450 (left->CanBeNegative() && | 1464 (left->CanBeNegative() && |
| 1451 instr->CanBeZero() && | 1465 instr->CanBeZero() && |
| 1452 instr->CheckFlag(HValue::kBailoutOnMinusZero))) | 1466 instr->CheckFlag(HValue::kBailoutOnMinusZero))) |
| 1453 ? AssignEnvironment(result) | 1467 ? AssignEnvironment(result) |
| 1454 : result; | 1468 : result; |
| 1455 } else { | 1469 } else { |
| 1456 LModI* mod = new(zone()) LModI(UseRegister(left), | 1470 LModI* mod = new(zone()) LModI(UseRegister(left), |
| 1457 UseRegister(right), | 1471 UseRegister(right), |
| 1458 FixedTemp(d10), | 1472 TempDoubleRegister(), |
| 1459 FixedTemp(d11)); | 1473 TempDoubleRegister()); |
| 1460 LInstruction* result = DefineAsRegister(mod); | 1474 LInstruction* result = DefineAsRegister(mod); |
| 1461 return (right->CanBeZero() || | 1475 return (right->CanBeZero() || |
| 1462 (left->CanBeNegative() && | 1476 (left->CanBeNegative() && |
| 1463 instr->CanBeZero() && | 1477 instr->CanBeZero() && |
| 1464 instr->CheckFlag(HValue::kBailoutOnMinusZero))) | 1478 instr->CheckFlag(HValue::kBailoutOnMinusZero))) |
| 1465 ? AssignEnvironment(result) | 1479 ? AssignEnvironment(result) |
| 1466 : result; | 1480 : result; |
| 1467 } | 1481 } |
| 1468 } else if (instr->representation().IsSmiOrTagged()) { | 1482 } else if (instr->representation().IsSmiOrTagged()) { |
| 1469 return DoArithmeticT(Token::MOD, instr); | 1483 return DoArithmeticT(Token::MOD, instr); |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1911 LOperand* value = NULL; | 1925 LOperand* value = NULL; |
| 1912 LInstruction* res = NULL; | 1926 LInstruction* res = NULL; |
| 1913 if (instr->value()->type().IsSmi()) { | 1927 if (instr->value()->type().IsSmi()) { |
| 1914 value = UseRegisterAtStart(instr->value()); | 1928 value = UseRegisterAtStart(instr->value()); |
| 1915 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); | 1929 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); |
| 1916 } else { | 1930 } else { |
| 1917 value = UseRegister(instr->value()); | 1931 value = UseRegister(instr->value()); |
| 1918 LOperand* temp1 = TempRegister(); | 1932 LOperand* temp1 = TempRegister(); |
| 1919 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() | 1933 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() |
| 1920 : NULL; | 1934 : NULL; |
| 1921 LOperand* temp3 = FixedTemp(d11); | 1935 LOperand* temp3 = TempDoubleRegister(); |
| 1922 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, | 1936 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, |
| 1923 temp1, | 1937 temp1, |
| 1924 temp2, | 1938 temp2, |
| 1925 temp3)); | 1939 temp3)); |
| 1926 res = AssignEnvironment(res); | 1940 res = AssignEnvironment(res); |
| 1927 } | 1941 } |
| 1928 return res; | 1942 return res; |
| 1929 } | 1943 } |
| 1930 } else if (from.IsDouble()) { | 1944 } else if (from.IsDouble()) { |
| 1931 if (to.IsTagged()) { | 1945 if (to.IsTagged()) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 LInstruction* result = new(zone()) LCheckMaps(value); | 2049 LInstruction* result = new(zone()) LCheckMaps(value); |
| 2036 return AssignEnvironment(result); | 2050 return AssignEnvironment(result); |
| 2037 } | 2051 } |
| 2038 | 2052 |
| 2039 | 2053 |
| 2040 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { | 2054 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { |
| 2041 HValue* value = instr->value(); | 2055 HValue* value = instr->value(); |
| 2042 Representation input_rep = value->representation(); | 2056 Representation input_rep = value->representation(); |
| 2043 LOperand* reg = UseRegister(value); | 2057 LOperand* reg = UseRegister(value); |
| 2044 if (input_rep.IsDouble()) { | 2058 if (input_rep.IsDouble()) { |
| 2045 return DefineAsRegister(new(zone()) LClampDToUint8(reg, FixedTemp(d11))); | 2059 return DefineAsRegister( |
| 2060 new(zone()) LClampDToUint8(reg, TempDoubleRegister())); |
| 2046 } else if (input_rep.IsInteger32()) { | 2061 } else if (input_rep.IsInteger32()) { |
| 2047 return DefineAsRegister(new(zone()) LClampIToUint8(reg)); | 2062 return DefineAsRegister(new(zone()) LClampIToUint8(reg)); |
| 2048 } else { | 2063 } else { |
| 2049 ASSERT(input_rep.IsSmiOrTagged()); | 2064 ASSERT(input_rep.IsSmiOrTagged()); |
| 2050 // Register allocator doesn't (yet) support allocation of double | 2065 LClampTToUint8* result = |
| 2051 // temps. Reserve d1 explicitly. | 2066 new(zone()) LClampTToUint8(reg, TempDoubleRegister()); |
| 2052 LClampTToUint8* result = new(zone()) LClampTToUint8(reg, FixedTemp(d11)); | |
| 2053 return AssignEnvironment(DefineAsRegister(result)); | 2067 return AssignEnvironment(DefineAsRegister(result)); |
| 2054 } | 2068 } |
| 2055 } | 2069 } |
| 2056 | 2070 |
| 2057 | 2071 |
| 2058 LInstruction* LChunkBuilder::DoReturn(HReturn* instr) { | 2072 LInstruction* LChunkBuilder::DoReturn(HReturn* instr) { |
| 2059 LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count()); | 2073 LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count()); |
| 2060 return new(zone()) LReturn(UseFixed(instr->value(), r0), | 2074 return new(zone()) LReturn(UseFixed(instr->value(), r0), |
| 2061 parameter_count); | 2075 parameter_count); |
| 2062 } | 2076 } |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2623 | 2637 |
| 2624 | 2638 |
| 2625 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2639 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2626 LOperand* object = UseRegister(instr->object()); | 2640 LOperand* object = UseRegister(instr->object()); |
| 2627 LOperand* index = UseRegister(instr->index()); | 2641 LOperand* index = UseRegister(instr->index()); |
| 2628 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2642 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2629 } | 2643 } |
| 2630 | 2644 |
| 2631 | 2645 |
| 2632 } } // namespace v8::internal | 2646 } } // namespace v8::internal |
| OLD | NEW |