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

Unified 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: REBASE Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index b699b43fe38b78dc0098e50657ce8e401befa0f3..503b56c5f44f737f4914e0e8822ea9ba02a823d4 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1755,11 +1755,12 @@ HInstruction* HGraphBuilder::BuildGetArrayFunction(HValue* context) {
HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder,
ElementsKind kind,
HValue* allocation_site_payload,
+ HValue* constructor_function,
bool disable_allocation_sites) :
builder_(builder),
kind_(kind),
allocation_site_payload_(allocation_site_payload),
- constructor_function_(NULL) {
+ constructor_function_(constructor_function) {
mode_ = disable_allocation_sites
? DONT_TRACK_ALLOCATION_SITE
: AllocationSiteInfo::GetMode(kind);
@@ -1778,17 +1779,23 @@ HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder,
HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) {
- HInstruction* native_context = builder()->BuildGetNativeContext(context);
+ if (kind_ == FAST_SMI_ELEMENTS) {
+ // Optimization: the initial Array map is for FAST_SMI_ELEMENTS.
+ // 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
+ HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap();
+ return AddInstruction(
+ builder()->BuildLoadNamedField(constructor_function_,
+ access,
+ Representation::Tagged()));
+ }
+ HInstruction* native_context = builder()->BuildGetNativeContext(context);
HInstruction* index = builder()->AddInstruction(new(zone())
HConstant(Context::JS_ARRAY_MAPS_INDEX));
-
HInstruction* map_array = builder()->AddInstruction(new(zone())
HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS));
-
HInstruction* kind_index = builder()->AddInstruction(new(zone())
- HConstant(kind_));
-
+ HConstant(kind_));
return builder()->AddInstruction(new(zone())
HLoadKeyed(map_array, kind_index, NULL, FAST_ELEMENTS));
}
@@ -1885,7 +1892,7 @@ HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes,
// Fill in the fields: map, properties, length
HValue* map;
- if (constructor_function_ != NULL) {
+ if (allocation_site_payload_ == NULL) {
map = EmitInternalMapCode();
} else {
map = EmitMapCode(context);
« src/code-stubs-hydrogen.cc ('K') | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698