From: svenpanne@chromium.org Date: Mon, 30 Jul 2012 10:42:21 +0000 (+0000) Subject: Inline simple getter calls. X-Git-Tag: upstream/4.7.83~16219 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb4840c0e55f305b9bd56f5c64447a6f5f07d809;p=platform%2Fupstream%2Fv8.git Inline simple getter calls. Currently only simple getter calls are handled (i.e. no calls in count operations or compound assignments), and deoptimization in the getter is not handled at all. Because of the latter, we temporarily hide this feature behind a new flag --inline-accessors, which is false by default. Review URL: https://chromiumcodereview.appspot.com/10828066 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12223 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index d2325f7..9bac93d 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -2275,6 +2275,7 @@ void FullCodeGenerator::VisitProperty(Property* expr) { if (key->IsPropertyName()) { VisitForAccumulatorValue(expr->obj()); EmitNamedPropertyLoad(expr); + PrepareForBailoutForId(expr->ReturnId(), TOS_REG); context()->Plug(r0); } else { VisitForStackValue(expr->obj()); diff --git a/src/ast.h b/src/ast.h index 8c9606a..63ee29a 100644 --- a/src/ast.h +++ b/src/ast.h @@ -1513,6 +1513,9 @@ class Property: public Expression { Expression* key() const { return key_; } virtual int position() const { return pos_; } + // Bailout support. + int ReturnId() const { return return_id_; } + bool IsStringLength() const { return is_string_length_; } bool IsStringAccess() const { return is_string_access_; } bool IsFunctionPrototype() const { return is_function_prototype_; } @@ -1535,6 +1538,7 @@ class Property: public Expression { obj_(obj), key_(key), pos_(pos), + return_id_(GetNextId(isolate)), is_monomorphic_(false), is_uninitialized_(false), is_array_length_(false), @@ -1546,6 +1550,7 @@ class Property: public Expression { Expression* obj_; Expression* key_; int pos_; + const int return_id_; SmallMapList receiver_types_; bool is_monomorphic_ : 1; diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 51918a5..19d7d37 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -213,6 +213,7 @@ DEFINE_bool(cache_optimized_code, true, "cache optimized code for closures") DEFINE_bool(inline_construct, true, "inline constructor calls") DEFINE_bool(inline_arguments, true, "inline functions with arguments object") +DEFINE_bool(inline_accessors, false, "inline JavaScript accessors") DEFINE_int(loop_weight, 1, "loop weight for representation inference") DEFINE_bool(optimize_for_in, true, diff --git a/src/hydrogen.cc b/src/hydrogen.cc index f614850..73c9173 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -6352,7 +6352,11 @@ void HGraphBuilder::VisitProperty(Property* expr) { Handle accessors; Handle holder; if (LookupAccessorPair(map, name, &accessors, &holder)) { - instr = BuildCallGetter(Pop(), map, accessors, holder); + AddCheckConstantFunction(holder, Top(), map, true); + Handle getter(JSFunction::cast(accessors->getter())); + if (FLAG_inline_accessors && TryInlineGetter(getter, expr)) return; + AddInstruction(new(zone()) HPushArgument(Pop())); + instr = new(zone()) HCallConstantFunction(getter, 1); } else { instr = BuildLoadNamedMonomorphic(Pop(), name, expr, map); } @@ -6920,6 +6924,18 @@ bool HGraphBuilder::TryInlineConstruct(CallNew* expr, HValue* receiver) { } +bool HGraphBuilder::TryInlineGetter(Handle getter, + Property* prop) { + return TryInline(CALL_AS_METHOD, + getter, + 0, + NULL, + prop->id(), + prop->ReturnId(), + NORMAL_RETURN); +} + + bool HGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra) { if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); diff --git a/src/hydrogen.h b/src/hydrogen.h index 3cdd7f8..61d792f 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -1040,6 +1040,7 @@ class HGraphBuilder: public AstVisitor { bool TryInlineCall(Call* expr, bool drop_extra = false); bool TryInlineConstruct(CallNew* expr, HValue* receiver); + bool TryInlineGetter(Handle getter, Property* prop); bool TryInlineBuiltinMethodCall(Call* expr, HValue* receiver, Handle receiver_map, diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index 75253c0..ceee56a 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -2214,6 +2214,7 @@ void FullCodeGenerator::VisitProperty(Property* expr) { VisitForAccumulatorValue(expr->obj()); __ mov(edx, result_register()); EmitNamedPropertyLoad(expr); + PrepareForBailoutForId(expr->ReturnId(), TOS_REG); context()->Plug(eax); } else { VisitForStackValue(expr->obj()); diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index 4a19d6c..a5e7dcf 100644 --- a/src/mips/full-codegen-mips.cc +++ b/src/mips/full-codegen-mips.cc @@ -2299,6 +2299,7 @@ void FullCodeGenerator::VisitProperty(Property* expr) { if (key->IsPropertyName()) { VisitForAccumulatorValue(expr->obj()); EmitNamedPropertyLoad(expr); + PrepareForBailoutForId(expr->ReturnId(), TOS_REG); context()->Plug(v0); } else { VisitForStackValue(expr->obj()); diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index 344905e..702ee29 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -2188,6 +2188,7 @@ void FullCodeGenerator::VisitProperty(Property* expr) { if (key->IsPropertyName()) { VisitForAccumulatorValue(expr->obj()); EmitNamedPropertyLoad(expr); + PrepareForBailoutForId(expr->ReturnId(), TOS_REG); context()->Plug(rax); } else { VisitForStackValue(expr->obj());