OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 | 580 |
581 #ifdef DEBUG | 581 #ifdef DEBUG |
582 void HInstruction::Verify() { | 582 void HInstruction::Verify() { |
583 // Verify that input operands are defined before use. | 583 // Verify that input operands are defined before use. |
584 HBasicBlock* cur_block = block(); | 584 HBasicBlock* cur_block = block(); |
585 for (int i = 0; i < OperandCount(); ++i) { | 585 for (int i = 0; i < OperandCount(); ++i) { |
586 HValue* other_operand = OperandAt(i); | 586 HValue* other_operand = OperandAt(i); |
587 HBasicBlock* other_block = other_operand->block(); | 587 HBasicBlock* other_block = other_operand->block(); |
588 if (cur_block == other_block) { | 588 if (cur_block == other_block) { |
589 if (!other_operand->IsPhi()) { | 589 if (!other_operand->IsPhi()) { |
590 HInstruction* cur = cur_block->first(); | 590 HInstruction* cur = this->previous(); |
591 while (cur != NULL) { | 591 while (cur != NULL) { |
592 ASSERT(cur != this); // We should reach other_operand before! | |
593 if (cur == other_operand) break; | 592 if (cur == other_operand) break; |
594 cur = cur->next(); | 593 cur = cur->previous(); |
595 } | 594 } |
596 // Must reach other operand in the same block! | 595 // Must reach other operand in the same block! |
597 ASSERT(cur == other_operand); | 596 ASSERT(cur == other_operand); |
598 } | 597 } |
599 } else { | 598 } else { |
600 // If the following assert fires, you may have forgotten an | 599 // If the following assert fires, you may have forgotten an |
601 // AddInstruction. | 600 // AddInstruction. |
602 ASSERT(other_block->Dominates(cur_block)); | 601 ASSERT(other_block->Dominates(cur_block)); |
603 } | 602 } |
604 } | 603 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 if (to_ == JS_FUNCTION_TYPE) stream->Add(" function"); | 775 if (to_ == JS_FUNCTION_TYPE) stream->Add(" function"); |
777 break; | 776 break; |
778 default: | 777 default: |
779 break; | 778 break; |
780 } | 779 } |
781 } | 780 } |
782 | 781 |
783 | 782 |
784 void HTypeofIsAndBranch::PrintDataTo(StringStream* stream) { | 783 void HTypeofIsAndBranch::PrintDataTo(StringStream* stream) { |
785 value()->PrintNameTo(stream); | 784 value()->PrintNameTo(stream); |
786 stream->Add(" == "); | 785 stream->Add(" == %o", *type_literal_); |
787 stream->Add(type_literal_->GetFlatContent().ToAsciiVector()); | |
788 HControlInstruction::PrintDataTo(stream); | 786 HControlInstruction::PrintDataTo(stream); |
789 } | 787 } |
790 | 788 |
791 | 789 |
| 790 HValue* HConstant::Canonicalize() { |
| 791 return HasNoUses() && !IsBlockEntry() ? NULL : this; |
| 792 } |
| 793 |
| 794 |
| 795 HValue* HTypeof::Canonicalize() { |
| 796 return HasNoUses() && !IsBlockEntry() ? NULL : this; |
| 797 } |
| 798 |
| 799 |
792 void HTypeof::PrintDataTo(StringStream* stream) { | 800 void HTypeof::PrintDataTo(StringStream* stream) { |
793 value()->PrintNameTo(stream); | 801 value()->PrintNameTo(stream); |
794 } | 802 } |
795 | 803 |
796 | 804 |
797 void HChange::PrintDataTo(StringStream* stream) { | 805 void HChange::PrintDataTo(StringStream* stream) { |
798 HUnaryOperation::PrintDataTo(stream); | 806 HUnaryOperation::PrintDataTo(stream); |
799 stream->Add(" %s to %s", from().Mnemonic(), to().Mnemonic()); | 807 stream->Add(" %s to %s", from().Mnemonic(), to().Mnemonic()); |
800 | 808 |
801 if (CanTruncateToInt32()) stream->Add(" truncating-int32"); | 809 if (CanTruncateToInt32()) stream->Add(" truncating-int32"); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 | 1139 |
1132 | 1140 |
1133 void HPhi::AddIndirectUsesTo(int* dest) { | 1141 void HPhi::AddIndirectUsesTo(int* dest) { |
1134 for (int i = 0; i < Representation::kNumRepresentations; i++) { | 1142 for (int i = 0; i < Representation::kNumRepresentations; i++) { |
1135 dest[i] += indirect_uses_[i]; | 1143 dest[i] += indirect_uses_[i]; |
1136 } | 1144 } |
1137 } | 1145 } |
1138 | 1146 |
1139 | 1147 |
1140 void HSimulate::PrintDataTo(StringStream* stream) { | 1148 void HSimulate::PrintDataTo(StringStream* stream) { |
1141 stream->Add("id=%d ", ast_id()); | 1149 stream->Add("id=%d", ast_id()); |
1142 if (pop_count_ > 0) stream->Add("pop %d", pop_count_); | 1150 if (pop_count_ > 0) stream->Add(" pop %d", pop_count_); |
1143 if (values_.length() > 0) { | 1151 if (values_.length() > 0) { |
1144 if (pop_count_ > 0) stream->Add(" /"); | 1152 if (pop_count_ > 0) stream->Add(" /"); |
1145 for (int i = 0; i < values_.length(); ++i) { | 1153 for (int i = 0; i < values_.length(); ++i) { |
1146 if (!HasAssignedIndexAt(i)) { | 1154 if (i > 0) stream->Add(","); |
| 1155 if (HasAssignedIndexAt(i)) { |
| 1156 stream->Add(" var[%d] = ", GetAssignedIndexAt(i)); |
| 1157 } else { |
1147 stream->Add(" push "); | 1158 stream->Add(" push "); |
1148 } else { | |
1149 stream->Add(" var[%d] = ", GetAssignedIndexAt(i)); | |
1150 } | 1159 } |
1151 values_[i]->PrintNameTo(stream); | 1160 values_[i]->PrintNameTo(stream); |
1152 } | 1161 } |
1153 } | 1162 } |
1154 } | 1163 } |
1155 | 1164 |
1156 | 1165 |
1157 void HDeoptimize::PrintDataTo(StringStream* stream) { | 1166 void HDeoptimize::PrintDataTo(StringStream* stream) { |
1158 if (OperandCount() == 0) return; | 1167 if (OperandCount() == 0) return; |
1159 OperandAt(0)->PrintNameTo(stream); | 1168 OperandAt(0)->PrintNameTo(stream); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 String::cast(*handle())->length() == 0) return false; | 1229 String::cast(*handle())->length() == 0) return false; |
1221 return true; | 1230 return true; |
1222 } | 1231 } |
1223 | 1232 |
1224 void HConstant::PrintDataTo(StringStream* stream) { | 1233 void HConstant::PrintDataTo(StringStream* stream) { |
1225 handle()->ShortPrint(stream); | 1234 handle()->ShortPrint(stream); |
1226 } | 1235 } |
1227 | 1236 |
1228 | 1237 |
1229 bool HArrayLiteral::IsCopyOnWrite() const { | 1238 bool HArrayLiteral::IsCopyOnWrite() const { |
1230 return constant_elements()->map() == HEAP->fixed_cow_array_map(); | 1239 Handle<FixedArray> constant_elements = this->constant_elements(); |
| 1240 FixedArrayBase* constant_elements_values = |
| 1241 FixedArrayBase::cast(constant_elements->get(1)); |
| 1242 return constant_elements_values->map() == HEAP->fixed_cow_array_map(); |
1231 } | 1243 } |
1232 | 1244 |
1233 | 1245 |
1234 void HBinaryOperation::PrintDataTo(StringStream* stream) { | 1246 void HBinaryOperation::PrintDataTo(StringStream* stream) { |
1235 left()->PrintNameTo(stream); | 1247 left()->PrintNameTo(stream); |
1236 stream->Add(" "); | 1248 stream->Add(" "); |
1237 right()->PrintNameTo(stream); | 1249 right()->PrintNameTo(stream); |
1238 if (CheckFlag(kCanOverflow)) stream->Add(" !"); | 1250 if (CheckFlag(kCanOverflow)) stream->Add(" !"); |
1239 if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?"); | 1251 if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?"); |
1240 } | 1252 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 name_(name), | 1397 name_(name), |
1386 need_generic_(false) { | 1398 need_generic_(false) { |
1387 SetOperandAt(0, context); | 1399 SetOperandAt(0, context); |
1388 SetOperandAt(1, object); | 1400 SetOperandAt(1, object); |
1389 set_representation(Representation::Tagged()); | 1401 set_representation(Representation::Tagged()); |
1390 SetFlag(kDependsOnMaps); | 1402 SetFlag(kDependsOnMaps); |
1391 for (int i = 0; | 1403 for (int i = 0; |
1392 i < types->length() && types_.length() < kMaxLoadPolymorphism; | 1404 i < types->length() && types_.length() < kMaxLoadPolymorphism; |
1393 ++i) { | 1405 ++i) { |
1394 Handle<Map> map = types->at(i); | 1406 Handle<Map> map = types->at(i); |
1395 LookupResult lookup; | 1407 LookupResult lookup(map->GetIsolate()); |
1396 map->LookupInDescriptors(NULL, *name, &lookup); | 1408 map->LookupInDescriptors(NULL, *name, &lookup); |
1397 if (lookup.IsProperty()) { | 1409 if (lookup.IsProperty()) { |
1398 switch (lookup.type()) { | 1410 switch (lookup.type()) { |
1399 case FIELD: { | 1411 case FIELD: { |
1400 int index = lookup.GetLocalFieldIndexFromMap(*map); | 1412 int index = lookup.GetLocalFieldIndexFromMap(*map); |
1401 if (index < 0) { | 1413 if (index < 0) { |
1402 SetFlag(kDependsOnInobjectFields); | 1414 SetFlag(kDependsOnInobjectFields); |
1403 } else { | 1415 } else { |
1404 SetFlag(kDependsOnBackingStoreFields); | 1416 SetFlag(kDependsOnBackingStoreFields); |
1405 } | 1417 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 } | 1450 } |
1439 } | 1451 } |
1440 if (!found) return false; | 1452 if (!found) return false; |
1441 } | 1453 } |
1442 return true; | 1454 return true; |
1443 } | 1455 } |
1444 | 1456 |
1445 | 1457 |
1446 void HLoadNamedFieldPolymorphic::PrintDataTo(StringStream* stream) { | 1458 void HLoadNamedFieldPolymorphic::PrintDataTo(StringStream* stream) { |
1447 object()->PrintNameTo(stream); | 1459 object()->PrintNameTo(stream); |
1448 stream->Add(" ."); | 1460 stream->Add("."); |
1449 stream->Add(*String::cast(*name())->ToCString()); | 1461 stream->Add(*String::cast(*name())->ToCString()); |
1450 } | 1462 } |
1451 | 1463 |
1452 | 1464 |
1453 void HLoadNamedGeneric::PrintDataTo(StringStream* stream) { | 1465 void HLoadNamedGeneric::PrintDataTo(StringStream* stream) { |
1454 object()->PrintNameTo(stream); | 1466 object()->PrintNameTo(stream); |
1455 stream->Add(" ."); | 1467 stream->Add("."); |
1456 stream->Add(*String::cast(*name())->ToCString()); | 1468 stream->Add(*String::cast(*name())->ToCString()); |
1457 } | 1469 } |
1458 | 1470 |
1459 | 1471 |
1460 void HLoadKeyedFastElement::PrintDataTo(StringStream* stream) { | 1472 void HLoadKeyedFastElement::PrintDataTo(StringStream* stream) { |
1461 object()->PrintNameTo(stream); | 1473 object()->PrintNameTo(stream); |
1462 stream->Add("["); | 1474 stream->Add("["); |
1463 key()->PrintNameTo(stream); | 1475 key()->PrintNameTo(stream); |
1464 stream->Add("]"); | 1476 stream->Add("]"); |
1465 } | 1477 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 ASSERT(name()->IsString()); | 1554 ASSERT(name()->IsString()); |
1543 stream->Add(*String::cast(*name())->ToCString()); | 1555 stream->Add(*String::cast(*name())->ToCString()); |
1544 stream->Add(" = "); | 1556 stream->Add(" = "); |
1545 value()->PrintNameTo(stream); | 1557 value()->PrintNameTo(stream); |
1546 } | 1558 } |
1547 | 1559 |
1548 | 1560 |
1549 void HStoreNamedField::PrintDataTo(StringStream* stream) { | 1561 void HStoreNamedField::PrintDataTo(StringStream* stream) { |
1550 object()->PrintNameTo(stream); | 1562 object()->PrintNameTo(stream); |
1551 stream->Add("."); | 1563 stream->Add("."); |
1552 ASSERT(name()->IsString()); | |
1553 stream->Add(*String::cast(*name())->ToCString()); | 1564 stream->Add(*String::cast(*name())->ToCString()); |
1554 stream->Add(" = "); | 1565 stream->Add(" = "); |
1555 value()->PrintNameTo(stream); | 1566 value()->PrintNameTo(stream); |
| 1567 stream->Add(" @%d%s", offset(), is_in_object() ? "[in-object]" : ""); |
1556 if (!transition().is_null()) { | 1568 if (!transition().is_null()) { |
1557 stream->Add(" (transition map %p)", *transition()); | 1569 stream->Add(" (transition map %p)", *transition()); |
1558 } | 1570 } |
1559 } | 1571 } |
1560 | 1572 |
1561 | 1573 |
1562 void HStoreKeyedFastElement::PrintDataTo(StringStream* stream) { | 1574 void HStoreKeyedFastElement::PrintDataTo(StringStream* stream) { |
1563 object()->PrintNameTo(stream); | 1575 object()->PrintNameTo(stream); |
1564 stream->Add("["); | 1576 stream->Add("["); |
1565 key()->PrintNameTo(stream); | 1577 key()->PrintNameTo(stream); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 UNREACHABLE(); | 1638 UNREACHABLE(); |
1627 break; | 1639 break; |
1628 } | 1640 } |
1629 stream->Add("["); | 1641 stream->Add("["); |
1630 key()->PrintNameTo(stream); | 1642 key()->PrintNameTo(stream); |
1631 stream->Add("] = "); | 1643 stream->Add("] = "); |
1632 value()->PrintNameTo(stream); | 1644 value()->PrintNameTo(stream); |
1633 } | 1645 } |
1634 | 1646 |
1635 | 1647 |
| 1648 void HTransitionElementsKind::PrintDataTo(StringStream* stream) { |
| 1649 object()->PrintNameTo(stream); |
| 1650 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); |
| 1651 } |
| 1652 |
| 1653 |
1636 void HLoadGlobalCell::PrintDataTo(StringStream* stream) { | 1654 void HLoadGlobalCell::PrintDataTo(StringStream* stream) { |
1637 stream->Add("[%p]", *cell()); | 1655 stream->Add("[%p]", *cell()); |
1638 if (!details_.IsDontDelete()) stream->Add(" (deleteable)"); | 1656 if (!details_.IsDontDelete()) stream->Add(" (deleteable)"); |
1639 if (details_.IsReadOnly()) stream->Add(" (read-only)"); | 1657 if (details_.IsReadOnly()) stream->Add(" (read-only)"); |
1640 } | 1658 } |
1641 | 1659 |
1642 | 1660 |
1643 bool HLoadGlobalCell::RequiresHoleCheck() { | 1661 bool HLoadGlobalCell::RequiresHoleCheck() { |
1644 if (details_.IsDontDelete() && !details_.IsReadOnly()) return false; | 1662 if (details_.IsDontDelete() && !details_.IsReadOnly()) return false; |
1645 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 1663 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 HType HDeleteProperty::CalculateInferredType() { | 1757 HType HDeleteProperty::CalculateInferredType() { |
1740 return HType::Boolean(); | 1758 return HType::Boolean(); |
1741 } | 1759 } |
1742 | 1760 |
1743 | 1761 |
1744 HType HInstanceOfKnownGlobal::CalculateInferredType() { | 1762 HType HInstanceOfKnownGlobal::CalculateInferredType() { |
1745 return HType::Boolean(); | 1763 return HType::Boolean(); |
1746 } | 1764 } |
1747 | 1765 |
1748 | 1766 |
| 1767 HType HChange::CalculateInferredType() { |
| 1768 if (from().IsDouble() && to().IsTagged()) return HType::HeapNumber(); |
| 1769 return type(); |
| 1770 } |
| 1771 |
| 1772 |
1749 HType HBitwiseBinaryOperation::CalculateInferredType() { | 1773 HType HBitwiseBinaryOperation::CalculateInferredType() { |
1750 return HType::TaggedNumber(); | 1774 return HType::TaggedNumber(); |
1751 } | 1775 } |
1752 | 1776 |
1753 | 1777 |
1754 HType HArithmeticBinaryOperation::CalculateInferredType() { | 1778 HType HArithmeticBinaryOperation::CalculateInferredType() { |
1755 return HType::TaggedNumber(); | 1779 return HType::TaggedNumber(); |
1756 } | 1780 } |
1757 | 1781 |
1758 | 1782 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 HType HShr::CalculateInferredType() { | 1818 HType HShr::CalculateInferredType() { |
1795 return HType::TaggedNumber(); | 1819 return HType::TaggedNumber(); |
1796 } | 1820 } |
1797 | 1821 |
1798 | 1822 |
1799 HType HSar::CalculateInferredType() { | 1823 HType HSar::CalculateInferredType() { |
1800 return HType::TaggedNumber(); | 1824 return HType::TaggedNumber(); |
1801 } | 1825 } |
1802 | 1826 |
1803 | 1827 |
| 1828 HType HStringCharFromCode::CalculateInferredType() { |
| 1829 return HType::String(); |
| 1830 } |
| 1831 |
| 1832 |
| 1833 HType HArrayLiteral::CalculateInferredType() { |
| 1834 return HType::JSArray(); |
| 1835 } |
| 1836 |
| 1837 |
| 1838 HType HObjectLiteral::CalculateInferredType() { |
| 1839 return HType::JSObject(); |
| 1840 } |
| 1841 |
| 1842 |
| 1843 HType HRegExpLiteral::CalculateInferredType() { |
| 1844 return HType::JSObject(); |
| 1845 } |
| 1846 |
| 1847 |
| 1848 HType HFunctionLiteral::CalculateInferredType() { |
| 1849 return HType::JSObject(); |
| 1850 } |
| 1851 |
| 1852 |
1804 HValue* HUnaryMathOperation::EnsureAndPropagateNotMinusZero( | 1853 HValue* HUnaryMathOperation::EnsureAndPropagateNotMinusZero( |
1805 BitVector* visited) { | 1854 BitVector* visited) { |
1806 visited->Add(id()); | 1855 visited->Add(id()); |
1807 if (representation().IsInteger32() && | 1856 if (representation().IsInteger32() && |
1808 !value()->representation().IsInteger32()) { | 1857 !value()->representation().IsInteger32()) { |
1809 if (value()->range() == NULL || value()->range()->CanBeMinusZero()) { | 1858 if (value()->range() == NULL || value()->range()->CanBeMinusZero()) { |
1810 SetFlag(kBailoutOnMinusZero); | 1859 SetFlag(kBailoutOnMinusZero); |
1811 } | 1860 } |
1812 } | 1861 } |
1813 if (RequiredInputRepresentation(0).IsInteger32() && | 1862 if (RequiredInputRepresentation(0).IsInteger32() && |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 | 1984 |
1936 | 1985 |
1937 void HCheckPrototypeMaps::Verify() { | 1986 void HCheckPrototypeMaps::Verify() { |
1938 HInstruction::Verify(); | 1987 HInstruction::Verify(); |
1939 ASSERT(HasNoUses()); | 1988 ASSERT(HasNoUses()); |
1940 } | 1989 } |
1941 | 1990 |
1942 #endif | 1991 #endif |
1943 | 1992 |
1944 } } // namespace v8::internal | 1993 } } // namespace v8::internal |
OLD | NEW |