Revision: 12223
Author:   [email protected]
Date:     Mon Jul 30 03:42:21 2012
Log:      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
http://code.google.com/p/v8/source/detail?r=12223

Modified:
 /branches/bleeding_edge/src/arm/full-codegen-arm.cc
 /branches/bleeding_edge/src/ast.h
 /branches/bleeding_edge/src/flag-definitions.h
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/hydrogen.h
 /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc
 /branches/bleeding_edge/src/mips/full-codegen-mips.cc
 /branches/bleeding_edge/src/x64/full-codegen-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/full-codegen-arm.cc Wed Jul 25 08:26:16 2012 +++ /branches/bleeding_edge/src/arm/full-codegen-arm.cc Mon Jul 30 03:42:21 2012
@@ -2275,6 +2275,7 @@
   if (key->IsPropertyName()) {
     VisitForAccumulatorValue(expr->obj());
     EmitNamedPropertyLoad(expr);
+    PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
     context()->Plug(r0);
   } else {
     VisitForStackValue(expr->obj());
=======================================
--- /branches/bleeding_edge/src/ast.h   Fri Jul 20 02:39:27 2012
+++ /branches/bleeding_edge/src/ast.h   Mon Jul 30 03:42:21 2012
@@ -1512,6 +1512,9 @@
   Expression* obj() const { return obj_; }
   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_; }
@@ -1535,6 +1538,7 @@
         obj_(obj),
         key_(key),
         pos_(pos),
+        return_id_(GetNextId(isolate)),
         is_monomorphic_(false),
         is_uninitialized_(false),
         is_array_length_(false),
@@ -1546,6 +1550,7 @@
   Expression* obj_;
   Expression* key_;
   int pos_;
+  const int return_id_;

   SmallMapList receiver_types_;
   bool is_monomorphic_ : 1;
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h      Thu Jul 26 07:21:40 2012
+++ /branches/bleeding_edge/src/flag-definitions.h      Mon Jul 30 03:42:21 2012
@@ -213,6 +213,7 @@
             "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,
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Fri Jul 27 05:35:44 2012
+++ /branches/bleeding_edge/src/hydrogen.cc     Mon Jul 30 03:42:21 2012
@@ -6352,7 +6352,11 @@
       Handle<AccessorPair> accessors;
       Handle<JSObject> holder;
       if (LookupAccessorPair(map, name, &accessors, &holder)) {
-        instr = BuildCallGetter(Pop(), map, accessors, holder);
+        AddCheckConstantFunction(holder, Top(), map, true);
+        Handle<JSFunction> 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);
       }
@@ -6918,6 +6922,18 @@
                    expr->ReturnId(),
                    CONSTRUCT_CALL_RETURN);
 }
+
+
+bool HGraphBuilder::TryInlineGetter(Handle<JSFunction> 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) {
=======================================
--- /branches/bleeding_edge/src/hydrogen.h      Fri Jul 27 02:43:06 2012
+++ /branches/bleeding_edge/src/hydrogen.h      Mon Jul 30 03:42:21 2012
@@ -1040,6 +1040,7 @@

   bool TryInlineCall(Call* expr, bool drop_extra = false);
   bool TryInlineConstruct(CallNew* expr, HValue* receiver);
+  bool TryInlineGetter(Handle<JSFunction> getter, Property* prop);
   bool TryInlineBuiltinMethodCall(Call* expr,
                                   HValue* receiver,
                                   Handle<Map> receiver_map,
=======================================
--- /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Wed Jul 25 07:27:14 2012 +++ /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Mon Jul 30 03:42:21 2012
@@ -2214,6 +2214,7 @@
     VisitForAccumulatorValue(expr->obj());
     __ mov(edx, result_register());
     EmitNamedPropertyLoad(expr);
+    PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
     context()->Plug(eax);
   } else {
     VisitForStackValue(expr->obj());
=======================================
--- /branches/bleeding_edge/src/mips/full-codegen-mips.cc Wed Jul 25 07:36:38 2012 +++ /branches/bleeding_edge/src/mips/full-codegen-mips.cc Mon Jul 30 03:42:21 2012
@@ -2299,6 +2299,7 @@
   if (key->IsPropertyName()) {
     VisitForAccumulatorValue(expr->obj());
     EmitNamedPropertyLoad(expr);
+    PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
     context()->Plug(v0);
   } else {
     VisitForStackValue(expr->obj());
=======================================
--- /branches/bleeding_edge/src/x64/full-codegen-x64.cc Wed Jul 25 07:27:14 2012 +++ /branches/bleeding_edge/src/x64/full-codegen-x64.cc Mon Jul 30 03:42:21 2012
@@ -2188,6 +2188,7 @@
   if (key->IsPropertyName()) {
     VisitForAccumulatorValue(expr->obj());
     EmitNamedPropertyLoad(expr);
+    PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
     context()->Plug(rax);
   } else {
     VisitForStackValue(expr->obj());

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to