Revision: 14934
Author:   [email protected]
Date:     Tue Jun  4 05:48:51 2013
Log: Turn off allocation site info for crankshafted array constructor calls.

Once we crankshaft a method, we should turn off allocation site info for
constructed arrays. Additionally, the semantics for doing this were
awkward because the constructed array code stubs get an
AllocationSiteMode as a minor key, but it's used as a permission to
determine the final mode locally based on ElementsKind. I refactored
this to a simpler boolean for override or local control.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/16206007
http://code.google.com/p/v8/source/detail?r=14934

Modified:
 /branches/bleeding_edge/src/arm/code-stubs-arm.cc
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
 /branches/bleeding_edge/src/code-stubs-hydrogen.cc
 /branches/bleeding_edge/src/code-stubs.h
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/hydrogen.h
 /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
 /branches/bleeding_edge/src/x64/code-stubs-x64.cc
 /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Tue Jun 4 03:30:05 2013 +++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Tue Jun 4 05:48:51 2013
@@ -7244,6 +7244,10 @@
     ElementsKind kind = GetFastElementsKindFromSequenceIndex(i);
     T stub(kind);
     stub.GetCode(isolate)->set_is_pregenerated(true);
+    if (AllocationSiteInfo::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) {
+      T stub1(kind, true);
+      stub1.GetCode(isolate)->set_is_pregenerated(true);
+    }
   }
 }

=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Jun 4 01:28:33 2013 +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Jun 4 05:48:51 2013
@@ -4229,14 +4229,17 @@
   __ mov(r0, Operand(instr->arity()));
   __ mov(r2, Operand(instr->hydrogen()->property_cell()));
   ElementsKind kind = instr->hydrogen()->elements_kind();
+  bool disable_allocation_sites =
+      (AllocationSiteInfo::GetMode(kind) == TRACK_ALLOCATION_SITE);
+
   if (instr->arity() == 0) {
-    ArrayNoArgumentConstructorStub stub(kind);
+    ArrayNoArgumentConstructorStub stub(kind, disable_allocation_sites);
     CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
   } else if (instr->arity() == 1) {
-    ArraySingleArgumentConstructorStub stub(kind);
+ ArraySingleArgumentConstructorStub stub(kind, disable_allocation_sites);
     CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
   } else {
-    ArrayNArgumentsConstructorStub stub(kind);
+    ArrayNArgumentsConstructorStub stub(kind, disable_allocation_sites);
     CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
   }
 }
=======================================
--- /branches/bleeding_edge/src/code-stubs-hydrogen.cc Mon Jun 3 08:32:22 2013 +++ /branches/bleeding_edge/src/code-stubs-hydrogen.cc Tue Jun 4 05:48:51 2013
@@ -537,7 +537,7 @@
       this,
       casted_stub()->elements_kind(),
       GetParameter(ArrayConstructorStubBase::kPropertyCell),
-      casted_stub()->mode());
+      casted_stub()->disable_allocation_sites());
   return array_builder.AllocateEmptyArray();
 }

@@ -589,7 +589,7 @@
       this,
       casted_stub()->elements_kind(),
       GetParameter(ArrayConstructorStubBase::kPropertyCell),
-      casted_stub()->mode());
+      casted_stub()->disable_allocation_sites());
   return array_builder.AllocateArray(capacity, length, true);
 }

@@ -612,7 +612,7 @@
       this,
       kind,
       GetParameter(ArrayConstructorStubBase::kPropertyCell),
-      casted_stub()->mode());
+      casted_stub()->disable_allocation_sites());

// We need to fill with the hole if it's a smi array in the multi-argument
   // case because we might have to bail out while copying arguments into
=======================================
--- /branches/bleeding_edge/src/code-stubs.h    Tue Jun  4 00:49:45 2013
+++ /branches/bleeding_edge/src/code-stubs.h    Tue Jun  4 05:48:51 2013
@@ -1726,19 +1726,22 @@

 class ArrayConstructorStubBase : public HydrogenCodeStub {
  public:
-  ArrayConstructorStubBase(ElementsKind kind, AllocationSiteMode mode) {
+ ArrayConstructorStubBase(ElementsKind kind, bool disable_allocation_sites) {
+    // It only makes sense to override local allocation site behavior
+    // if there is a difference between the global allocation site policy
+    // for an ElementsKind and the desired usage of the stub.
+    ASSERT(!disable_allocation_sites ||
+           AllocationSiteInfo::GetMode(kind) == TRACK_ALLOCATION_SITE);
     bit_field_ = ElementsKindBits::encode(kind) |
-        AllocationSiteModeBits::encode(mode == TRACK_ALLOCATION_SITE);
+        DisableAllocationSitesBits::encode(disable_allocation_sites);
   }

   ElementsKind elements_kind() const {
     return ElementsKindBits::decode(bit_field_);
   }

-  AllocationSiteMode mode() const {
-    return AllocationSiteModeBits::decode(bit_field_)
-        ? TRACK_ALLOCATION_SITE
-        : DONT_TRACK_ALLOCATION_SITE;
+  bool disable_allocation_sites() const {
+    return DisableAllocationSitesBits::decode(bit_field_);
   }

   virtual bool IsPregenerated() { return true; }
@@ -1753,7 +1756,7 @@
   int NotMissMinorKey() { return bit_field_; }

   class ElementsKindBits: public BitField<ElementsKind, 0, 8> {};
-  class AllocationSiteModeBits: public BitField<bool, 8, 1> {};
+  class DisableAllocationSitesBits: public BitField<bool, 8, 1> {};
   uint32_t bit_field_;

   DISALLOW_COPY_AND_ASSIGN(ArrayConstructorStubBase);
@@ -1764,8 +1767,8 @@
  public:
   ArrayNoArgumentConstructorStub(
       ElementsKind kind,
-      AllocationSiteMode mode = TRACK_ALLOCATION_SITE)
-      : ArrayConstructorStubBase(kind, mode) {
+      bool disable_allocation_sites = false)
+      : ArrayConstructorStubBase(kind, disable_allocation_sites) {
   }

   virtual Handle<Code> GenerateCode();
@@ -1785,8 +1788,8 @@
  public:
   ArraySingleArgumentConstructorStub(
       ElementsKind kind,
-      AllocationSiteMode mode = TRACK_ALLOCATION_SITE)
-      : ArrayConstructorStubBase(kind, mode) {
+      bool disable_allocation_sites = false)
+      : ArrayConstructorStubBase(kind, disable_allocation_sites) {
   }

   virtual Handle<Code> GenerateCode();
@@ -1806,8 +1809,8 @@
  public:
   ArrayNArgumentsConstructorStub(
       ElementsKind kind,
-      AllocationSiteMode mode = TRACK_ALLOCATION_SITE) :
-    ArrayConstructorStubBase(kind, mode) {
+      bool disable_allocation_sites = false)
+      : ArrayConstructorStubBase(kind, disable_allocation_sites) {
   }

   virtual Handle<Code> GenerateCode();
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Tue Jun  4 01:28:33 2013
+++ /branches/bleeding_edge/src/hydrogen.cc     Tue Jun  4 05:48:51 2013
@@ -1766,15 +1766,13 @@
 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder,
                                               ElementsKind kind,
HValue* allocation_site_payload,
-                                              AllocationSiteMode mode) :
+ bool disable_allocation_sites) :
         builder_(builder),
         kind_(kind),
         allocation_site_payload_(allocation_site_payload) {
-  if (mode == DONT_TRACK_ALLOCATION_SITE) {
-    mode_ = mode;
-  } else {
-    mode_ = AllocationSiteInfo::GetMode(kind);
-  }
+  mode_ = disable_allocation_sites
+      ? DONT_TRACK_ALLOCATION_SITE
+      : AllocationSiteInfo::GetMode(kind);
 }


=======================================
--- /branches/bleeding_edge/src/hydrogen.h      Tue Jun  4 01:28:33 2013
+++ /branches/bleeding_edge/src/hydrogen.h      Tue Jun  4 05:48:51 2013
@@ -1232,7 +1232,7 @@
     JSArrayBuilder(HGraphBuilder* builder,
                    ElementsKind kind,
                    HValue* allocation_site_payload,
-                   AllocationSiteMode mode);
+                   bool disable_allocation_sites);

     HValue* AllocateEmptyArray();
     HValue* AllocateArray(HValue* capacity, HValue* length_field,
=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Tue Jun 4 03:30:05 2013 +++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Tue Jun 4 05:48:51 2013
@@ -7823,8 +7823,12 @@
       TERMINAL_FAST_ELEMENTS_KIND);
   for (int i = 0; i <= to_index; ++i) {
     ElementsKind kind = GetFastElementsKindFromSequenceIndex(i);
-    T stub(kind);
+    T stub(kind, false);
     stub.GetCode(isolate)->set_is_pregenerated(true);
+    if (AllocationSiteInfo::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) {
+      T stub1(kind, true);
+      stub1.GetCode(isolate)->set_is_pregenerated(true);
+    }
   }
 }

=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Jun 4 01:28:33 2013 +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Jun 4 05:48:51 2013
@@ -4238,14 +4238,17 @@
   __ Set(eax, Immediate(instr->arity()));
   __ mov(ebx, instr->hydrogen()->property_cell());
   ElementsKind kind = instr->hydrogen()->elements_kind();
+  bool disable_allocation_sites =
+      (AllocationSiteInfo::GetMode(kind) == TRACK_ALLOCATION_SITE);
+
   if (instr->arity() == 0) {
-    ArrayNoArgumentConstructorStub stub(kind);
+    ArrayNoArgumentConstructorStub stub(kind, disable_allocation_sites);
     CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
   } else if (instr->arity() == 1) {
-    ArraySingleArgumentConstructorStub stub(kind);
+ ArraySingleArgumentConstructorStub stub(kind, disable_allocation_sites);
     CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
   } else {
-    ArrayNArgumentsConstructorStub stub(kind);
+    ArrayNArgumentsConstructorStub stub(kind, disable_allocation_sites);
     CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
   }
 }
=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.cc Tue Jun 4 03:30:05 2013 +++ /branches/bleeding_edge/src/x64/code-stubs-x64.cc Tue Jun 4 05:48:51 2013
@@ -6830,6 +6830,10 @@
     ElementsKind kind = GetFastElementsKindFromSequenceIndex(i);
     T stub(kind);
     stub.GetCode(isolate)->set_is_pregenerated(true);
+    if (AllocationSiteInfo::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) {
+      T stub1(kind, true);
+      stub1.GetCode(isolate)->set_is_pregenerated(true);
+    }
   }
 }

=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Jun 4 01:28:33 2013 +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Jun 4 05:48:51 2013
@@ -3935,14 +3935,17 @@
   __ Set(rax, instr->arity());
   __ Move(rbx, instr->hydrogen()->property_cell());
   ElementsKind kind = instr->hydrogen()->elements_kind();
+  bool disable_allocation_sites =
+      (AllocationSiteInfo::GetMode(kind) == TRACK_ALLOCATION_SITE);
+
   if (instr->arity() == 0) {
-    ArrayNoArgumentConstructorStub stub(kind);
+    ArrayNoArgumentConstructorStub stub(kind, disable_allocation_sites);
     CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
   } else if (instr->arity() == 1) {
-    ArraySingleArgumentConstructorStub stub(kind);
+ ArraySingleArgumentConstructorStub stub(kind, disable_allocation_sites);
     CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
   } else {
-    ArrayNArgumentsConstructorStub stub(kind);
+    ArrayNArgumentsConstructorStub stub(kind, disable_allocation_sites);
     CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
   }
 }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to