From 045fbe46b13ceb9af5b99c04c9990f56348e63b6 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Mon, 22 Sep 2014 12:43:40 +0000 Subject: [PATCH] Pass the ast_id to HandleKeyed to make sure it's the right one (e.g., CountOperation, not just the load-expression's id) BUG= R=jarin@chromium.org Review URL: https://codereview.chromium.org/595453002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24117 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/hydrogen.cc | 8 ++++---- src/hydrogen.h | 3 ++- test/mjsunit/keyed-named-access.js | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/hydrogen.cc b/src/hydrogen.cc index e5a93a7..848178c 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -6436,7 +6436,7 @@ 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, return_id, STORE, + HandleKeyedElementAccess(object, key, value, expr, ast_id, return_id, STORE, &has_side_effects); Drop(3); Push(value); @@ -7129,7 +7129,7 @@ HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess( HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( - HValue* obj, HValue* key, HValue* val, Expression* expr, + HValue* obj, HValue* key, HValue* val, Expression* expr, BailoutId ast_id, BailoutId return_id, PropertyAccessType access_type, bool* has_side_effects) { if (key->ActualValue()->IsConstant()) { @@ -7143,7 +7143,7 @@ HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( Handle::cast(constant)); } HInstruction* instr = - BuildNamedAccess(access_type, expr->id(), return_id, expr, obj, + BuildNamedAccess(access_type, ast_id, return_id, expr, obj, Handle::cast(constant), val, false); if (instr == NULL || instr->IsLinked()) { *has_side_effects = false; @@ -7365,7 +7365,7 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr, bool has_side_effects = false; HValue* load = HandleKeyedElementAccess( - obj, key, NULL, expr, expr->LoadId(), LOAD, &has_side_effects); + obj, key, NULL, expr, ast_id, expr->LoadId(), LOAD, &has_side_effects); if (has_side_effects) { if (ast_context()->IsEffect()) { Add(ast_id, REMOVABLE_SIMULATE); diff --git a/src/hydrogen.h b/src/hydrogen.h index 6b03170..d5e208f 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -2627,7 +2627,8 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { bool* has_side_effects); HValue* HandleKeyedElementAccess(HValue* obj, HValue* key, HValue* val, - Expression* expr, BailoutId return_id, + Expression* expr, BailoutId ast_id, + BailoutId return_id, PropertyAccessType access_type, bool* has_side_effects); diff --git a/test/mjsunit/keyed-named-access.js b/test/mjsunit/keyed-named-access.js index f9541e8..11f8fb5 100644 --- a/test/mjsunit/keyed-named-access.js +++ b/test/mjsunit/keyed-named-access.js @@ -34,3 +34,39 @@ f(o3); f(o3); %OptimizeFunctionOnNextCall(f); assertEquals(1200, f(o3)); + +(function CountOperationDeoptimizationGetter() { + var global = {}; + global.__defineGetter__("A", function () { return "x"; }); + + function h() { + return "A"; + } + + function g(a, b, c) { + try { + return a + b.toString() + c; + } catch (e) { } + } + + function test(o) { + return g(1, o[h()]--, 10); + } + + test(global); + test(global); + %OptimizeFunctionOnNextCall(test); + print(test(global)); +})(); + + +(function CountOperationDeoptimizationPoint() { + function test() { + this[0, ""]--; + } + + test(); + test(); + %OptimizeFunctionOnNextCall(test); + test(); +})(); -- 2.7.4