Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: src/hydrogen.cc

Issue 17091002: Hydrogen array constructor cleanup and improvements (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed nit Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 HInstruction* native_context = BuildGetNativeContext(context); 1746 HInstruction* native_context = BuildGetNativeContext(context);
1747 HInstruction* index = AddInstruction(new(zone()) 1747 HInstruction* index = AddInstruction(new(zone())
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 bool disable_allocation_sites) : 1758 HValue* constructor_function,
1759 AllocationSiteOverrideMode override_mode) :
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_ = override_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_ == GetInitialFastElementsKind()) {
1783 // No need for a context lookup if the kind_ matches the initial
1784 // map, because we can just load the map in that case.
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
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 9639 matching lines...) Expand 10 before | Expand all | Expand 10 after
11538 if (ShouldProduceTraceOutput()) { 11545 if (ShouldProduceTraceOutput()) {
11539 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11546 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11540 } 11547 }
11541 11548
11542 #ifdef DEBUG 11549 #ifdef DEBUG
11543 graph_->Verify(false); // No full verify. 11550 graph_->Verify(false); // No full verify.
11544 #endif 11551 #endif
11545 } 11552 }
11546 11553
11547 } } // namespace v8::internal 11554 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698