From 21e09fa8dd958f20273a1401315a529029e359ff Mon Sep 17 00:00:00 2001 From: "plind44@gmail.com" Date: Wed, 19 Mar 2014 15:46:24 +0000 Subject: [PATCH] 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= R=plind44@gmail.com Review URL: https://codereview.chromium.org/204613002 Patch from Balazs Kilvady . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20086 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mips/builtins-mips.cc | 8 ++----- src/mips/code-stubs-mips.cc | 49 ++++++++++++++++------------------------ src/mips/lithium-codegen-mips.cc | 6 ++--- 3 files changed, 24 insertions(+), 39 deletions(-) diff --git a/src/mips/builtins-mips.cc b/src/mips/builtins-mips.cc index b0a70a2..cd96d99 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 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 megamorphic_sentinel = - TypeFeedbackInfo::MegamorphicSentinel(masm->isolate()); - __ li(a2, Operand(megamorphic_sentinel)); + __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); __ CallStub(&stub); } else { diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index 82e1b17..0d00f7b 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 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); diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 827503e..e306c17 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -3914,9 +3914,7 @@ void LCodeGen::DoCallNew(LCallNew* instr) { __ li(a0, Operand(instr->arity())); // No cell in a2 for construct type feedback in optimized code - Handle 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); } @@ -3928,7 +3926,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) -- 2.7.4