From eda4b5bcd2ef98264feeff3755a678c8a95d2f6c Mon Sep 17 00:00:00 2001 From: "akos.palfi" Date: Tue, 31 Mar 2015 12:53:03 -0700 Subject: [PATCH] MIPS64: Ensure object literal element boilerplates aren't modified. Port 7c347c545e33d279b5aa476e754a5358201be846 BUG= Review URL: https://codereview.chromium.org/1049793002 Cr-Commit-Position: refs/heads/master@{#27555} --- src/mips64/full-codegen-mips64.cc | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/src/mips64/full-codegen-mips64.cc b/src/mips64/full-codegen-mips64.cc index 525b04a..91d374a 100644 --- a/src/mips64/full-codegen-mips64.cc +++ b/src/mips64/full-codegen-mips64.cc @@ -1682,21 +1682,12 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { __ ld(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); __ li(a1, Operand(constant_properties)); - int flags = expr->fast_elements() - ? ObjectLiteral::kFastElements - : ObjectLiteral::kNoFlags; - flags |= expr->has_function() - ? ObjectLiteral::kHasFunction - : ObjectLiteral::kNoFlags; - __ li(a0, Operand(Smi::FromInt(flags))); - int properties_count = constant_properties->length() / 2; - if (expr->may_store_doubles() || expr->depth() > 1 || - masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements || - properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { + __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); + if (MustCreateObjectLiteralWithRuntime(expr)) { __ Push(a3, a2, a1, a0); __ CallRuntime(Runtime::kCreateObjectLiteral, 4); } else { - FastCloneShallowObjectStub stub(isolate(), properties_count); + FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); __ CallStub(&stub); } PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); @@ -1888,21 +1879,10 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { Comment cmnt(masm_, "[ ArrayLiteral"); expr->BuildConstantElements(isolate()); - int flags = expr->depth() == 1 - ? ArrayLiteral::kShallowElements - : ArrayLiteral::kNoFlags; - - ZoneList* subexprs = expr->values(); - int length = subexprs->length(); Handle constant_elements = expr->constant_elements(); - DCHECK_EQ(2, constant_elements->length()); - ElementsKind constant_elements_kind = - static_cast(Smi::cast(constant_elements->get(0))->value()); bool has_fast_elements = - IsFastObjectElementsKind(constant_elements_kind); - Handle constant_elements_values( - FixedArrayBase::cast(constant_elements->get(1))); + IsFastObjectElementsKind(expr->constant_elements_kind()); AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; if (has_fast_elements && !FLAG_allocation_site_pretenuring) { @@ -1916,8 +1896,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { __ ld(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); __ li(a1, Operand(constant_elements)); - if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { - __ li(a0, Operand(Smi::FromInt(flags))); + if (MustCreateArrayLiteralWithRuntime(expr)) { + __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); __ Push(a3, a2, a1, a0); __ CallRuntime(Runtime::kCreateArrayLiteral, 4); } else { @@ -1927,6 +1907,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); bool result_saved = false; // Is the result saved to the stack? + ZoneList* subexprs = expr->values(); + int length = subexprs->length(); // Emit code to evaluate all the non-constant subexpressions and to store // them into the newly cloned array. @@ -1944,7 +1926,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { VisitForAccumulatorValue(subexpr); - if (IsFastObjectElementsKind(constant_elements_kind)) { + if (has_fast_elements) { int offset = FixedArray::kHeaderSize + (i * kPointerSize); __ ld(a6, MemOperand(sp, kPointerSize)); // Copy of array literal. __ ld(a1, FieldMemOperand(a6, JSObject::kElementsOffset)); -- 2.7.4