OLD | NEW |
1 // Copyright 2011 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 return result; | 1031 return result; |
1032 } | 1032 } |
1033 | 1033 |
1034 | 1034 |
1035 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 1035 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
1036 return new LGoto(instr->FirstSuccessor()->block_id()); | 1036 return new LGoto(instr->FirstSuccessor()->block_id()); |
1037 } | 1037 } |
1038 | 1038 |
1039 | 1039 |
1040 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { | 1040 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { |
1041 HValue* v = instr->value(); | 1041 HValue* value = instr->value(); |
1042 if (v->EmitAtUses()) { | 1042 if (value->EmitAtUses()) { |
1043 HBasicBlock* successor = HConstant::cast(v)->ToBoolean() | 1043 HBasicBlock* successor = HConstant::cast(value)->ToBoolean() |
1044 ? instr->FirstSuccessor() | 1044 ? instr->FirstSuccessor() |
1045 : instr->SecondSuccessor(); | 1045 : instr->SecondSuccessor(); |
1046 return new LGoto(successor->block_id()); | 1046 return new LGoto(successor->block_id()); |
1047 } | 1047 } |
1048 return AssignEnvironment(new LBranch(UseRegister(v))); | 1048 |
| 1049 LBranch* result = new LBranch(UseRegister(value)); |
| 1050 // Tagged values that are not known smis or booleans require a |
| 1051 // deoptimization environment. |
| 1052 Representation rep = value->representation(); |
| 1053 HType type = value->type(); |
| 1054 if (rep.IsTagged() && !type.IsSmi() && !type.IsBoolean()) { |
| 1055 return AssignEnvironment(result); |
| 1056 } |
| 1057 return result; |
1049 } | 1058 } |
1050 | 1059 |
1051 | 1060 |
1052 | 1061 |
1053 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { | 1062 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { |
1054 ASSERT(instr->value()->representation().IsTagged()); | 1063 ASSERT(instr->value()->representation().IsTagged()); |
1055 LOperand* value = UseRegisterAtStart(instr->value()); | 1064 LOperand* value = UseRegisterAtStart(instr->value()); |
1056 LOperand* temp = TempRegister(); | 1065 LOperand* temp = TempRegister(); |
1057 return new LCmpMapAndBranch(value, temp); | 1066 return new LCmpMapAndBranch(value, temp); |
1058 } | 1067 } |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 LOperand* right = UseOrConstant(instr->MostConstantOperand()); | 1346 LOperand* right = UseOrConstant(instr->MostConstantOperand()); |
1338 LOperand* temp = NULL; | 1347 LOperand* temp = NULL; |
1339 if (instr->CheckFlag(HValue::kBailoutOnMinusZero) && | 1348 if (instr->CheckFlag(HValue::kBailoutOnMinusZero) && |
1340 (instr->CheckFlag(HValue::kCanOverflow) || | 1349 (instr->CheckFlag(HValue::kCanOverflow) || |
1341 !right->IsConstantOperand())) { | 1350 !right->IsConstantOperand())) { |
1342 left = UseRegister(instr->LeastConstantOperand()); | 1351 left = UseRegister(instr->LeastConstantOperand()); |
1343 temp = TempRegister(); | 1352 temp = TempRegister(); |
1344 } else { | 1353 } else { |
1345 left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1354 left = UseRegisterAtStart(instr->LeastConstantOperand()); |
1346 } | 1355 } |
1347 return AssignEnvironment(DefineAsRegister(new LMulI(left, right, temp))); | 1356 LMulI* mul = new LMulI(left, right, temp); |
| 1357 if (instr->CheckFlag(HValue::kCanOverflow) || |
| 1358 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1359 AssignEnvironment(mul); |
| 1360 } |
| 1361 return DefineAsRegister(mul); |
1348 | 1362 |
1349 } else if (instr->representation().IsDouble()) { | 1363 } else if (instr->representation().IsDouble()) { |
1350 return DoArithmeticD(Token::MUL, instr); | 1364 return DoArithmeticD(Token::MUL, instr); |
1351 | 1365 |
1352 } else { | 1366 } else { |
1353 return DoArithmeticT(Token::MUL, instr); | 1367 return DoArithmeticT(Token::MUL, instr); |
1354 } | 1368 } |
1355 } | 1369 } |
1356 | 1370 |
1357 | 1371 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 LOperand* right = exponent_type.IsDouble() ? | 1420 LOperand* right = exponent_type.IsDouble() ? |
1407 UseFixedDouble(instr->right(), d2) : | 1421 UseFixedDouble(instr->right(), d2) : |
1408 UseFixed(instr->right(), r2); | 1422 UseFixed(instr->right(), r2); |
1409 LPower* result = new LPower(left, right); | 1423 LPower* result = new LPower(left, right); |
1410 return MarkAsCall(DefineFixedDouble(result, d3), | 1424 return MarkAsCall(DefineFixedDouble(result, d3), |
1411 instr, | 1425 instr, |
1412 CAN_DEOPTIMIZE_EAGERLY); | 1426 CAN_DEOPTIMIZE_EAGERLY); |
1413 } | 1427 } |
1414 | 1428 |
1415 | 1429 |
| 1430 LInstruction* LChunkBuilder::DoRandom(HRandom* instr) { |
| 1431 ASSERT(instr->representation().IsDouble()); |
| 1432 ASSERT(instr->global_object()->representation().IsTagged()); |
| 1433 LOperand* global_object = UseFixed(instr->global_object(), r0); |
| 1434 LRandom* result = new LRandom(global_object); |
| 1435 return MarkAsCall(DefineFixedDouble(result, d7), instr); |
| 1436 } |
| 1437 |
| 1438 |
1416 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { | 1439 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { |
1417 ASSERT(instr->left()->representation().IsTagged()); | 1440 ASSERT(instr->left()->representation().IsTagged()); |
1418 ASSERT(instr->right()->representation().IsTagged()); | 1441 ASSERT(instr->right()->representation().IsTagged()); |
1419 LOperand* left = UseFixed(instr->left(), r1); | 1442 LOperand* left = UseFixed(instr->left(), r1); |
1420 LOperand* right = UseFixed(instr->right(), r0); | 1443 LOperand* right = UseFixed(instr->right(), r0); |
1421 LCmpT* result = new LCmpT(left, right); | 1444 LCmpT* result = new LCmpT(left, right); |
1422 return MarkAsCall(DefineFixed(result, r0), instr); | 1445 return MarkAsCall(DefineFixed(result, r0), instr); |
1423 } | 1446 } |
1424 | 1447 |
1425 | 1448 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 HHasCachedArrayIndexAndBranch* instr) { | 1545 HHasCachedArrayIndexAndBranch* instr) { |
1523 ASSERT(instr->value()->representation().IsTagged()); | 1546 ASSERT(instr->value()->representation().IsTagged()); |
1524 return new LHasCachedArrayIndexAndBranch( | 1547 return new LHasCachedArrayIndexAndBranch( |
1525 UseRegisterAtStart(instr->value())); | 1548 UseRegisterAtStart(instr->value())); |
1526 } | 1549 } |
1527 | 1550 |
1528 | 1551 |
1529 LInstruction* LChunkBuilder::DoClassOfTestAndBranch( | 1552 LInstruction* LChunkBuilder::DoClassOfTestAndBranch( |
1530 HClassOfTestAndBranch* instr) { | 1553 HClassOfTestAndBranch* instr) { |
1531 ASSERT(instr->value()->representation().IsTagged()); | 1554 ASSERT(instr->value()->representation().IsTagged()); |
1532 return new LClassOfTestAndBranch(UseTempRegister(instr->value()), | 1555 return new LClassOfTestAndBranch(UseRegister(instr->value()), |
1533 TempRegister()); | 1556 TempRegister()); |
1534 } | 1557 } |
1535 | 1558 |
1536 | 1559 |
1537 LInstruction* LChunkBuilder::DoJSArrayLength(HJSArrayLength* instr) { | 1560 LInstruction* LChunkBuilder::DoJSArrayLength(HJSArrayLength* instr) { |
1538 LOperand* array = UseRegisterAtStart(instr->value()); | 1561 LOperand* array = UseRegisterAtStart(instr->value()); |
1539 return DefineAsRegister(new LJSArrayLength(array)); | 1562 return DefineAsRegister(new LJSArrayLength(array)); |
1540 } | 1563 } |
1541 | 1564 |
1542 | 1565 |
1543 LInstruction* LChunkBuilder::DoFixedArrayBaseLength( | 1566 LInstruction* LChunkBuilder::DoFixedArrayBaseLength( |
1544 HFixedArrayBaseLength* instr) { | 1567 HFixedArrayBaseLength* instr) { |
1545 LOperand* array = UseRegisterAtStart(instr->value()); | 1568 LOperand* array = UseRegisterAtStart(instr->value()); |
1546 return DefineAsRegister(new LFixedArrayBaseLength(array)); | 1569 return DefineAsRegister(new LFixedArrayBaseLength(array)); |
1547 } | 1570 } |
1548 | 1571 |
1549 | 1572 |
1550 LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) { | 1573 LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) { |
1551 LOperand* object = UseRegisterAtStart(instr->value()); | 1574 LOperand* object = UseRegisterAtStart(instr->value()); |
1552 return DefineAsRegister(new LElementsKind(object)); | 1575 return DefineAsRegister(new LElementsKind(object)); |
1553 } | 1576 } |
1554 | 1577 |
1555 | 1578 |
1556 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { | 1579 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { |
1557 LOperand* object = UseRegister(instr->value()); | 1580 LOperand* object = UseRegister(instr->value()); |
1558 LValueOf* result = new LValueOf(object, TempRegister()); | 1581 LValueOf* result = new LValueOf(object, TempRegister()); |
1559 return AssignEnvironment(DefineAsRegister(result)); | 1582 return DefineAsRegister(result); |
1560 } | 1583 } |
1561 | 1584 |
1562 | 1585 |
1563 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { | 1586 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { |
1564 return AssignEnvironment(new LBoundsCheck(UseRegisterAtStart(instr->index()), | 1587 return AssignEnvironment(new LBoundsCheck(UseRegisterAtStart(instr->index()), |
1565 UseRegister(instr->length()))); | 1588 UseRegister(instr->length()))); |
1566 } | 1589 } |
1567 | 1590 |
1568 | 1591 |
1569 LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) { | 1592 LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) { |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 } | 1890 } |
1868 | 1891 |
1869 | 1892 |
1870 LInstruction* LChunkBuilder::DoLoadKeyedFastElement( | 1893 LInstruction* LChunkBuilder::DoLoadKeyedFastElement( |
1871 HLoadKeyedFastElement* instr) { | 1894 HLoadKeyedFastElement* instr) { |
1872 ASSERT(instr->representation().IsTagged()); | 1895 ASSERT(instr->representation().IsTagged()); |
1873 ASSERT(instr->key()->representation().IsInteger32()); | 1896 ASSERT(instr->key()->representation().IsInteger32()); |
1874 LOperand* obj = UseRegisterAtStart(instr->object()); | 1897 LOperand* obj = UseRegisterAtStart(instr->object()); |
1875 LOperand* key = UseRegisterAtStart(instr->key()); | 1898 LOperand* key = UseRegisterAtStart(instr->key()); |
1876 LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key); | 1899 LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key); |
1877 return AssignEnvironment(DefineAsRegister(result)); | 1900 if (instr->RequiresHoleCheck()) AssignEnvironment(result); |
| 1901 return DefineAsRegister(result); |
1878 } | 1902 } |
1879 | 1903 |
1880 | 1904 |
1881 LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement( | 1905 LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement( |
1882 HLoadKeyedFastDoubleElement* instr) { | 1906 HLoadKeyedFastDoubleElement* instr) { |
1883 ASSERT(instr->representation().IsDouble()); | 1907 ASSERT(instr->representation().IsDouble()); |
1884 ASSERT(instr->key()->representation().IsInteger32()); | 1908 ASSERT(instr->key()->representation().IsInteger32()); |
1885 LOperand* elements = UseTempRegister(instr->elements()); | 1909 LOperand* elements = UseTempRegister(instr->elements()); |
1886 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 1910 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
1887 LLoadKeyedFastDoubleElement* result = | 1911 LLoadKeyedFastDoubleElement* result = |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2238 | 2262 |
2239 LInstruction* LChunkBuilder::DoIn(HIn* instr) { | 2263 LInstruction* LChunkBuilder::DoIn(HIn* instr) { |
2240 LOperand* key = UseRegisterAtStart(instr->key()); | 2264 LOperand* key = UseRegisterAtStart(instr->key()); |
2241 LOperand* object = UseRegisterAtStart(instr->object()); | 2265 LOperand* object = UseRegisterAtStart(instr->object()); |
2242 LIn* result = new LIn(key, object); | 2266 LIn* result = new LIn(key, object); |
2243 return MarkAsCall(DefineFixed(result, r0), instr); | 2267 return MarkAsCall(DefineFixed(result, r0), instr); |
2244 } | 2268 } |
2245 | 2269 |
2246 | 2270 |
2247 } } // namespace v8::internal | 2271 } } // namespace v8::internal |
OLD | NEW |