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 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1748 HConstant(Context::ARRAY_FUNCTION_INDEX)); | 1748 HConstant(Context::ARRAY_FUNCTION_INDEX)); |
1749 | 1749 |
1750 return AddInstruction(new (zone()) | 1750 return AddInstruction(new (zone()) |
1751 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS)); | 1751 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS)); |
1752 } | 1752 } |
1753 | 1753 |
1754 | 1754 |
1755 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, | 1755 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
1756 ElementsKind kind, | 1756 ElementsKind kind, |
1757 HValue* allocation_site_payload, | 1757 HValue* allocation_site_payload, |
1758 HValue* constructor_function, | |
1758 bool disable_allocation_sites) : | 1759 bool disable_allocation_sites) : |
1759 builder_(builder), | 1760 builder_(builder), |
1760 kind_(kind), | 1761 kind_(kind), |
1761 allocation_site_payload_(allocation_site_payload), | 1762 allocation_site_payload_(allocation_site_payload), |
1762 constructor_function_(NULL) { | 1763 constructor_function_(constructor_function) { |
1763 mode_ = disable_allocation_sites | 1764 mode_ = disable_allocation_sites |
1764 ? DONT_TRACK_ALLOCATION_SITE | 1765 ? DONT_TRACK_ALLOCATION_SITE |
1765 : AllocationSiteInfo::GetMode(kind); | 1766 : AllocationSiteInfo::GetMode(kind); |
1766 } | 1767 } |
1767 | 1768 |
1768 | 1769 |
1769 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, | 1770 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
1770 ElementsKind kind, | 1771 ElementsKind kind, |
1771 HValue* constructor_function) : | 1772 HValue* constructor_function) : |
1772 builder_(builder), | 1773 builder_(builder), |
1773 kind_(kind), | 1774 kind_(kind), |
1774 mode_(DONT_TRACK_ALLOCATION_SITE), | 1775 mode_(DONT_TRACK_ALLOCATION_SITE), |
1775 allocation_site_payload_(NULL), | 1776 allocation_site_payload_(NULL), |
1776 constructor_function_(constructor_function) { | 1777 constructor_function_(constructor_function) { |
1777 } | 1778 } |
1778 | 1779 |
1779 | 1780 |
1780 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) { | 1781 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) { |
1782 if (kind_ == FAST_SMI_ELEMENTS) { | |
1783 // Optimization: the initial Array map is for FAST_SMI_ELEMENTS. | |
1784 // No need for a context lookup in this case. | |
danno
2013/06/27 08:53:04
Why not? What is special about smi elements?
mvstanton
2013/06/27 15:33:29
Because the initial map on the constructor is setu
| |
1785 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); | |
1786 return AddInstruction( | |
1787 builder()->BuildLoadNamedField(constructor_function_, | |
1788 access, | |
1789 Representation::Tagged())); | |
1790 } | |
1791 | |
1781 HInstruction* native_context = builder()->BuildGetNativeContext(context); | 1792 HInstruction* native_context = builder()->BuildGetNativeContext(context); |
1782 | |
1783 HInstruction* index = builder()->AddInstruction(new(zone()) | 1793 HInstruction* index = builder()->AddInstruction(new(zone()) |
1784 HConstant(Context::JS_ARRAY_MAPS_INDEX)); | 1794 HConstant(Context::JS_ARRAY_MAPS_INDEX)); |
1785 | |
1786 HInstruction* map_array = builder()->AddInstruction(new(zone()) | 1795 HInstruction* map_array = builder()->AddInstruction(new(zone()) |
1787 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS)); | 1796 HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS)); |
1788 | |
1789 HInstruction* kind_index = builder()->AddInstruction(new(zone()) | 1797 HInstruction* kind_index = builder()->AddInstruction(new(zone()) |
1790 HConstant(kind_)); | 1798 HConstant(kind_)); |
1791 | |
1792 return builder()->AddInstruction(new(zone()) | 1799 return builder()->AddInstruction(new(zone()) |
1793 HLoadKeyed(map_array, kind_index, NULL, FAST_ELEMENTS)); | 1800 HLoadKeyed(map_array, kind_index, NULL, FAST_ELEMENTS)); |
1794 } | 1801 } |
1795 | 1802 |
1796 | 1803 |
1797 HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() { | 1804 HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() { |
1798 // Find the map near the constructor function | 1805 // Find the map near the constructor function |
1799 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); | 1806 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); |
1800 return AddInstruction( | 1807 return AddInstruction( |
1801 builder()->BuildLoadNamedField(constructor_function_, | 1808 builder()->BuildLoadNamedField(constructor_function_, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1878 HValue* context = builder()->environment()->LookupContext(); | 1885 HValue* context = builder()->environment()->LookupContext(); |
1879 | 1886 |
1880 // Allocate (dealing with failure appropriately) | 1887 // Allocate (dealing with failure appropriately) |
1881 HAllocate::Flags flags = HAllocate::DefaultFlags(kind_); | 1888 HAllocate::Flags flags = HAllocate::DefaultFlags(kind_); |
1882 HAllocate* new_object = new(zone()) HAllocate(context, size_in_bytes, | 1889 HAllocate* new_object = new(zone()) HAllocate(context, size_in_bytes, |
1883 HType::JSArray(), flags); | 1890 HType::JSArray(), flags); |
1884 AddInstruction(new_object); | 1891 AddInstruction(new_object); |
1885 | 1892 |
1886 // Fill in the fields: map, properties, length | 1893 // Fill in the fields: map, properties, length |
1887 HValue* map; | 1894 HValue* map; |
1888 if (constructor_function_ != NULL) { | 1895 if (allocation_site_payload_ == NULL) { |
1889 map = EmitInternalMapCode(); | 1896 map = EmitInternalMapCode(); |
1890 } else { | 1897 } else { |
1891 map = EmitMapCode(context); | 1898 map = EmitMapCode(context); |
1892 } | 1899 } |
1893 elements_location_ = builder()->BuildJSArrayHeader(new_object, | 1900 elements_location_ = builder()->BuildJSArrayHeader(new_object, |
1894 map, | 1901 map, |
1895 mode_, | 1902 mode_, |
1896 allocation_site_payload_, | 1903 allocation_site_payload_, |
1897 length_field); | 1904 length_field); |
1898 | 1905 |
(...skipping 9655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11554 if (ShouldProduceTraceOutput()) { | 11561 if (ShouldProduceTraceOutput()) { |
11555 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11562 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11556 } | 11563 } |
11557 | 11564 |
11558 #ifdef DEBUG | 11565 #ifdef DEBUG |
11559 graph_->Verify(false); // No full verify. | 11566 graph_->Verify(false); // No full verify. |
11560 #endif | 11567 #endif |
11561 } | 11568 } |
11562 | 11569 |
11563 } } // namespace v8::internal | 11570 } } // namespace v8::internal |
OLD | NEW |