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

Unified Diff: src/hydrogen.cc

Issue 585433002: Turn keyed loads with string-based (non-convertible to array-index) key into named loads (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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
« no previous file with comments | « src/hydrogen.h ('k') | test/mjsunit/keyed-named-access.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 37ecb1b50613b84af9e9335b75108c145caa0a52..9e025f7964476b753224cc5e468cc0e5e61dd596 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -6436,8 +6436,8 @@ void HOptimizedGraphBuilder::BuildStore(Expression* expr,
HValue* key = environment()->ExpressionStackAt(1);
HValue* object = environment()->ExpressionStackAt(2);
bool has_side_effects = false;
- HandleKeyedElementAccess(object, key, value, expr,
- STORE, &has_side_effects);
+ HandleKeyedElementAccess(object, key, value, expr, return_id, STORE,
+ &has_side_effects);
Drop(3);
Push(value);
Add<HSimulate>(return_id, REMOVABLE_SIMULATE);
@@ -7129,12 +7129,28 @@ HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess(
HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess(
- HValue* obj,
- HValue* key,
- HValue* val,
- Expression* expr,
- PropertyAccessType access_type,
+ HValue* obj, HValue* key, HValue* val, Expression* expr,
+ BailoutId return_id, PropertyAccessType access_type,
bool* has_side_effects) {
+ if (key->ActualValue()->IsConstant()) {
+ Handle<Object> constant =
+ HConstant::cast(key->ActualValue())->handle(isolate());
+ uint32_t array_index;
+ if (constant->IsString() &&
+ !Handle<String>::cast(constant)->AsArrayIndex(&array_index)) {
+ HInstruction* instr =
+ BuildNamedAccess(access_type, expr->id(), return_id, expr, obj,
+ Handle<String>::cast(constant), val, false);
+ if (instr == NULL || instr->IsLinked()) {
+ *has_side_effects = false;
+ } else {
+ AddInstruction(instr);
+ *has_side_effects = instr->HasObservableSideEffects();
+ }
+ return instr;
+ }
+ }
+
DCHECK(!expr->IsPropertyName());
HInstruction* instr = NULL;
@@ -7345,7 +7361,7 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr,
bool has_side_effects = false;
HValue* load = HandleKeyedElementAccess(
- obj, key, NULL, expr, LOAD, &has_side_effects);
+ obj, key, NULL, expr, expr->LoadId(), LOAD, &has_side_effects);
if (has_side_effects) {
if (ast_context()->IsEffect()) {
Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
@@ -7355,6 +7371,7 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr,
Drop(1);
}
}
+ if (load == NULL) return;
return ast_context()->ReturnValue(load);
}
return ast_context()->ReturnInstruction(instr, ast_id);
« no previous file with comments | « src/hydrogen.h ('k') | test/mjsunit/keyed-named-access.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698