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 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 } | 779 } |
780 | 780 |
781 | 781 |
782 void HTypeofIsAndBranch::PrintDataTo(StringStream* stream) { | 782 void HTypeofIsAndBranch::PrintDataTo(StringStream* stream) { |
783 value()->PrintNameTo(stream); | 783 value()->PrintNameTo(stream); |
784 stream->Add(" == %o", *type_literal_); | 784 stream->Add(" == %o", *type_literal_); |
785 HControlInstruction::PrintDataTo(stream); | 785 HControlInstruction::PrintDataTo(stream); |
786 } | 786 } |
787 | 787 |
788 | 788 |
| 789 void HCheckMapValue::PrintDataTo(StringStream* stream) { |
| 790 value()->PrintNameTo(stream); |
| 791 stream->Add(" "); |
| 792 map()->PrintNameTo(stream); |
| 793 } |
| 794 |
| 795 |
| 796 void HForInPrepareMap::PrintDataTo(StringStream* stream) { |
| 797 enumerable()->PrintNameTo(stream); |
| 798 } |
| 799 |
| 800 |
| 801 void HForInCacheArray::PrintDataTo(StringStream* stream) { |
| 802 enumerable()->PrintNameTo(stream); |
| 803 stream->Add(" "); |
| 804 map()->PrintNameTo(stream); |
| 805 stream->Add("[%d]", idx_); |
| 806 } |
| 807 |
| 808 |
| 809 void HLoadFieldByIndex::PrintDataTo(StringStream* stream) { |
| 810 object()->PrintNameTo(stream); |
| 811 stream->Add(" "); |
| 812 index()->PrintNameTo(stream); |
| 813 } |
| 814 |
| 815 |
789 HValue* HConstant::Canonicalize() { | 816 HValue* HConstant::Canonicalize() { |
790 return HasNoUses() && !IsBlockEntry() ? NULL : this; | 817 return HasNoUses() && !IsBlockEntry() ? NULL : this; |
791 } | 818 } |
792 | 819 |
793 | 820 |
794 HValue* HTypeof::Canonicalize() { | 821 HValue* HTypeof::Canonicalize() { |
795 return HasNoUses() && !IsBlockEntry() ? NULL : this; | 822 return HasNoUses() && !IsBlockEntry() ? NULL : this; |
796 } | 823 } |
797 | 824 |
798 | 825 |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 | 1539 |
1513 void HLoadKeyedFastElement::PrintDataTo(StringStream* stream) { | 1540 void HLoadKeyedFastElement::PrintDataTo(StringStream* stream) { |
1514 object()->PrintNameTo(stream); | 1541 object()->PrintNameTo(stream); |
1515 stream->Add("["); | 1542 stream->Add("["); |
1516 key()->PrintNameTo(stream); | 1543 key()->PrintNameTo(stream); |
1517 stream->Add("]"); | 1544 stream->Add("]"); |
1518 } | 1545 } |
1519 | 1546 |
1520 | 1547 |
1521 bool HLoadKeyedFastElement::RequiresHoleCheck() { | 1548 bool HLoadKeyedFastElement::RequiresHoleCheck() { |
| 1549 if (hole_check_mode_ == OMIT_HOLE_CHECK) { |
| 1550 return false; |
| 1551 } |
| 1552 |
1522 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 1553 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
1523 HValue* use = it.value(); | 1554 HValue* use = it.value(); |
1524 if (!use->IsChange()) return true; | 1555 if (!use->IsChange()) return true; |
1525 } | 1556 } |
| 1557 |
1526 return false; | 1558 return false; |
1527 } | 1559 } |
1528 | 1560 |
1529 | 1561 |
1530 void HLoadKeyedFastDoubleElement::PrintDataTo(StringStream* stream) { | 1562 void HLoadKeyedFastDoubleElement::PrintDataTo(StringStream* stream) { |
1531 elements()->PrintNameTo(stream); | 1563 elements()->PrintNameTo(stream); |
1532 stream->Add("["); | 1564 stream->Add("["); |
1533 key()->PrintNameTo(stream); | 1565 key()->PrintNameTo(stream); |
1534 stream->Add("]"); | 1566 stream->Add("]"); |
1535 } | 1567 } |
1536 | 1568 |
1537 | 1569 |
1538 void HLoadKeyedGeneric::PrintDataTo(StringStream* stream) { | 1570 void HLoadKeyedGeneric::PrintDataTo(StringStream* stream) { |
1539 object()->PrintNameTo(stream); | 1571 object()->PrintNameTo(stream); |
1540 stream->Add("["); | 1572 stream->Add("["); |
1541 key()->PrintNameTo(stream); | 1573 key()->PrintNameTo(stream); |
1542 stream->Add("]"); | 1574 stream->Add("]"); |
1543 } | 1575 } |
1544 | 1576 |
1545 | 1577 |
| 1578 HValue* HLoadKeyedGeneric::Canonicalize() { |
| 1579 // Recognize generic keyed loads that use property name generated |
| 1580 // by for-in statement as a key and rewrite them into fast property load |
| 1581 // by index. |
| 1582 if (key()->IsLoadKeyedFastElement()) { |
| 1583 HLoadKeyedFastElement* key_load = HLoadKeyedFastElement::cast(key()); |
| 1584 if (key_load->object()->IsForInCacheArray()) { |
| 1585 HForInCacheArray* names_cache = |
| 1586 HForInCacheArray::cast(key_load->object()); |
| 1587 |
| 1588 if (names_cache->enumerable() == object()) { |
| 1589 HForInCacheArray* index_cache = |
| 1590 names_cache->index_cache(); |
| 1591 HCheckMapValue* map_check = |
| 1592 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); |
| 1593 HInstruction* index = new(block()->zone()) HLoadKeyedFastElement( |
| 1594 index_cache, |
| 1595 key_load->key(), |
| 1596 HLoadKeyedFastElement::OMIT_HOLE_CHECK); |
| 1597 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( |
| 1598 object(), index); |
| 1599 map_check->InsertBefore(this); |
| 1600 index->InsertBefore(this); |
| 1601 load->InsertBefore(this); |
| 1602 return load; |
| 1603 } |
| 1604 } |
| 1605 } |
| 1606 |
| 1607 return this; |
| 1608 } |
| 1609 |
| 1610 |
1546 void HLoadKeyedSpecializedArrayElement::PrintDataTo( | 1611 void HLoadKeyedSpecializedArrayElement::PrintDataTo( |
1547 StringStream* stream) { | 1612 StringStream* stream) { |
1548 external_pointer()->PrintNameTo(stream); | 1613 external_pointer()->PrintNameTo(stream); |
1549 stream->Add("."); | 1614 stream->Add("."); |
1550 switch (elements_kind()) { | 1615 switch (elements_kind()) { |
1551 case EXTERNAL_BYTE_ELEMENTS: | 1616 case EXTERNAL_BYTE_ELEMENTS: |
1552 stream->Add("byte"); | 1617 stream->Add("byte"); |
1553 break; | 1618 break; |
1554 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 1619 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
1555 stream->Add("u_byte"); | 1620 stream->Add("u_byte"); |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 | 2227 |
2163 | 2228 |
2164 void HCheckPrototypeMaps::Verify() { | 2229 void HCheckPrototypeMaps::Verify() { |
2165 HInstruction::Verify(); | 2230 HInstruction::Verify(); |
2166 ASSERT(HasNoUses()); | 2231 ASSERT(HasNoUses()); |
2167 } | 2232 } |
2168 | 2233 |
2169 #endif | 2234 #endif |
2170 | 2235 |
2171 } } // namespace v8::internal | 2236 } } // namespace v8::internal |
OLD | NEW |