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

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: Add test 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 675b61155ba937a9c518bfb5cd16cbfa3be39306..10fcdeb6fbf5d7cd87ac8a03ce678ecca3102bde 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -6430,8 +6430,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);
@@ -7123,12 +7123,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(), expr->id(), expr, obj,
Igor Sheludko 2014/09/18 11:25:37 As you noticed you didn't use return_id here.
+ Handle<String>::cast(constant), val, false);
Igor Sheludko 2014/09/18 11:25:37 If instr really can't be null here then consider a
+ if (instr->IsLinked()) {
+ *has_side_effects = false;
+ } else {
+ AddInstruction(instr);
+ *has_side_effects = instr->HasObservableSideEffects();
+ }
+ return instr;
+ }
+ }
+
DCHECK(!expr->IsPropertyName());
HInstruction* instr = NULL;
@@ -7339,7 +7355,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);
« 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