Reviewers: danno, mvstanton, Paul Lind, palfia, kisg, dusmil,

Description:
MIPS: Array constructor expects AllocationSite or undefined as feedback.

Port r20064 (d2ccdc6)

Original commit message:
Redefine Array constructor to expect an AllocationSite in the feedback
register or undefined. This will make code simpler as we support
pretenuring feedback for all constructed objects.

BUG=

Please review this at https://codereview.chromium.org/204613002/

SVN Base: https://github.com/v8/v8.git@gbl

Affected files (+24, -39 lines):
  M src/mips/builtins-mips.cc
  M src/mips/code-stubs-mips.cc
  M src/mips/lithium-codegen-mips.cc


Index: src/mips/builtins-mips.cc
diff --git a/src/mips/builtins-mips.cc b/src/mips/builtins-mips.cc
index b0a70a21329d76b2539751dfbf057c7bfad3081b..cd96d9961c712f5863c7c8191dd30eadf303a5d6 100644
--- a/src/mips/builtins-mips.cc
+++ b/src/mips/builtins-mips.cc
@@ -163,9 +163,7 @@ void Builtins::Generate_ArrayCode(MacroAssembler* masm) {

// Run the native code for the Array function called as a normal function.
   // Tail call a stub.
-  Handle<Object> megamorphic_sentinel =
-      TypeFeedbackInfo::MegamorphicSentinel(masm->isolate());
-  __ li(a2, Operand(megamorphic_sentinel));
+  __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
   ArrayConstructorStub stub(masm->isolate());
   __ TailCallStub(&stub);
 }
@@ -756,9 +754,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
     __ mov(a0, a3);
     if (is_construct) {
       // No type feedback cell is available
-      Handle<Object> megamorphic_sentinel =
-          TypeFeedbackInfo::MegamorphicSentinel(masm->isolate());
-      __ li(a2, Operand(megamorphic_sentinel));
+      __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
       CallConstructStub stub(NO_CALL_FUNCTION_FLAGS);
       __ CallStub(&stub);
     } else {
Index: src/mips/code-stubs-mips.cc
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc
index 82e1b1745ede5e674f2ece66ff88ac34a8591d29..0d00f7bbb21e128933833045c548b6980174daa4 100644
--- a/src/mips/code-stubs-mips.cc
+++ b/src/mips/code-stubs-mips.cc
@@ -3184,6 +3184,10 @@ void CallFunctionStub::Generate(MacroAssembler* masm) {

     if (RecordCallTarget()) {
       GenerateRecordCallTarget(masm);
+      // Type information was updated. Because we may call Array, which
+      // expects either undefined or an AllocationSite in a2 we need
+      // to set a2 to undefined.
+      __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
     }
   }

@@ -3284,7 +3288,19 @@ void CallConstructStub::Generate(MacroAssembler* masm) {
   __ Branch(&slow, ne, t0, Operand(JS_FUNCTION_TYPE));

   if (RecordCallTarget()) {
+    Label feedback_register_initialized;
     GenerateRecordCallTarget(masm);
+
+ // Put the AllocationSite from the feedback vector into a2, or undefined.
+    __ sll(at, a3, kPointerSizeLog2 - kSmiTagSize);
+    __ Addu(t1, a2, at);
+    __ lw(a2, FieldMemOperand(t1, FixedArray::kHeaderSize));
+    __ lw(t1, FieldMemOperand(a2, AllocationSite::kMapOffset));
+    __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex);
+    __ Branch(&feedback_register_initialized, eq, t1, Operand(at));
+    __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
+    __ bind(&feedback_register_initialized);
+    __ AssertUndefinedOrAllocationSite(a2, t1);
   }

   // Jump to the function-specific construct stub.
@@ -5397,15 +5413,11 @@ void ArrayConstructorStub::Generate(MacroAssembler* masm) {
   // ----------- S t a t e -------------
   //  -- a0 : argc (only if argument_count_ == ANY)
   //  -- a1 : constructor
-  //  -- a2 : feedback vector (fixed array or megamorphic symbol)
-  //  -- a3 : slot index (if a2 is fixed array)
+  //  -- a2 : AllocationSite or undefined
   //  -- sp[0] : return address
   //  -- sp[4] : last argument
   // -----------------------------------

-  ASSERT_EQ(*TypeFeedbackInfo::MegamorphicSentinel(masm->isolate()),
-            masm->isolate()->heap()->megamorphic_symbol());
-
   if (FLAG_debug_code) {
     // The array construct code is only set for the global and natives
     // builtin Array functions which always have maps.
@@ -5420,35 +5432,14 @@ void ArrayConstructorStub::Generate(MacroAssembler* masm) {
     __ Assert(eq, kUnexpectedInitialMapForArrayFunction,
         t1, Operand(MAP_TYPE));

-    // We should either have the megamorphic symbol in a2 or a valid
-    // fixed array.
-    Label okay_here;
- Handle<Map> fixed_array_map = masm->isolate()->factory()->fixed_array_map();
-    __ LoadRoot(at, Heap::kMegamorphicSymbolRootIndex);
-    __ Branch(&okay_here, eq, a2, Operand(at));
-    __ lw(t0, FieldMemOperand(a2, 0));
-    __ Assert(eq, kExpectedFixedArrayInRegisterA2,
-        t0, Operand(fixed_array_map));
-
-    // a3 should be a smi if we don't have undefined in a2
-    __ AssertSmi(a3);
-
-    __ bind(&okay_here);
+    // We should either have undefined in a2 or a valid AllocationSite
+    __ AssertUndefinedOrAllocationSite(a2, t0);
   }

   Label no_info;
   // Get the elements kind and case on that.
-  __ LoadRoot(at, Heap::kMegamorphicSymbolRootIndex);
+  __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
   __ Branch(&no_info, eq, a2, Operand(at));
-  __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize);
-  __ Addu(a2, a2, Operand(t0));
-  __ lw(a2, FieldMemOperand(a2, FixedArray::kHeaderSize));
-
- // If the feedback vector is undefined, or contains anything other than an - // AllocationSite, call an array constructor that doesn't use AllocationSites.
-  __ lw(t0, FieldMemOperand(a2, 0));
-  __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex);
-  __ Branch(&no_info, ne, t0, Operand(at));

   __ lw(a3, FieldMemOperand(a2, AllocationSite::kTransitionInfoOffset));
   __ SmiUntag(a3);
Index: src/mips/lithium-codegen-mips.cc
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 7311db6a127da5d04fed5dac8aef783b55e89a1a..b657f8dee89524c1402421eea03fccbb613d33aa 100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -3917,9 +3917,7 @@ void LCodeGen::DoCallNew(LCallNew* instr) {

   __ li(a0, Operand(instr->arity()));
   // No cell in a2 for construct type feedback in optimized code
-  Handle<Object> megamorphic_symbol =
-      TypeFeedbackInfo::MegamorphicSentinel(isolate());
-  __ li(a2, Operand(megamorphic_symbol));
+  __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
   CallConstructStub stub(NO_CALL_FUNCTION_FLAGS);
   CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
 }
@@ -3931,7 +3929,7 @@ void LCodeGen::DoCallNewArray(LCallNewArray* instr) {
   ASSERT(ToRegister(instr->result()).is(v0));

   __ li(a0, Operand(instr->arity()));
-  __ li(a2, Operand(TypeFeedbackInfo::MegamorphicSentinel(isolate())));
+  __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
   ElementsKind kind = instr->hydrogen()->elements_kind();
   AllocationSiteOverrideMode override_mode =
       (AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE)


--
--
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/d/optout.

Reply via email to