@@ -1670,23 +1670,13 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1670
1670
__ Ldr (x3, FieldMemOperand (x3, JSFunction::kLiteralsOffset ));
1671
1671
__ Mov (x2, Smi::FromInt (expr->literal_index ()));
1672
1672
__ Mov (x1, Operand (constant_properties));
1673
- int flags = expr->fast_elements ()
1674
- ? ObjectLiteral::kFastElements
1675
- : ObjectLiteral::kNoFlags ;
1676
- flags |= expr->has_function ()
1677
- ? ObjectLiteral::kHasFunction
1678
- : ObjectLiteral::kNoFlags ;
1673
+ int flags = expr->ComputeFlags ();
1679
1674
__ Mov (x0, Smi::FromInt (flags));
1680
- int properties_count = constant_properties->length () / 2 ;
1681
- const int max_cloned_properties =
1682
- FastCloneShallowObjectStub::kMaximumClonedProperties ;
1683
- if (expr->may_store_doubles () || expr->depth () > 1 ||
1684
- masm ()->serializer_enabled () || flags != ObjectLiteral::kFastElements ||
1685
- properties_count > max_cloned_properties) {
1675
+ if (MustCreateObjectLiteralWithRuntime (expr)) {
1686
1676
__ Push (x3, x2, x1, x0);
1687
1677
__ CallRuntime (Runtime::kCreateObjectLiteral , 4 );
1688
1678
} else {
1689
- FastCloneShallowObjectStub stub (isolate (), properties_count);
1679
+ FastCloneShallowObjectStub stub (isolate (), expr-> properties_count () );
1690
1680
__ CallStub (&stub);
1691
1681
}
1692
1682
PrepareForBailoutForId (expr->CreateLiteralId (), TOS_REG);
@@ -1878,18 +1868,9 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1878
1868
Comment cmnt (masm_, " [ ArrayLiteral" );
1879
1869
1880
1870
expr->BuildConstantElements (isolate ());
1881
- int flags = (expr->depth () == 1 ) ? ArrayLiteral::kShallowElements
1882
- : ArrayLiteral::kNoFlags ;
1883
-
1884
- ZoneList<Expression*>* subexprs = expr->values ();
1885
- int length = subexprs->length ();
1886
1871
Handle <FixedArray> constant_elements = expr->constant_elements ();
1887
- DCHECK_EQ (2 , constant_elements->length ());
1888
- ElementsKind constant_elements_kind =
1889
- static_cast <ElementsKind>(Smi::cast (constant_elements->get (0 ))->value ());
1890
- bool has_fast_elements = IsFastObjectElementsKind (constant_elements_kind);
1891
- Handle <FixedArrayBase> constant_elements_values (
1892
- FixedArrayBase::cast (constant_elements->get (1 )));
1872
+ bool has_fast_elements =
1873
+ IsFastObjectElementsKind (expr->constant_elements_kind ());
1893
1874
1894
1875
AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE;
1895
1876
if (has_fast_elements && !FLAG_allocation_site_pretenuring) {
@@ -1902,8 +1883,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1902
1883
__ Ldr (x3, FieldMemOperand (x3, JSFunction::kLiteralsOffset ));
1903
1884
__ Mov (x2, Smi::FromInt (expr->literal_index ()));
1904
1885
__ Mov (x1, Operand (constant_elements));
1905
- if (expr-> depth () > 1 || length > JSObject:: kInitialMaxFastElementArray ) {
1906
- __ Mov (x0, Smi::FromInt (flags ));
1886
+ if (MustCreateArrayLiteralWithRuntime (expr) ) {
1887
+ __ Mov (x0, Smi::FromInt (expr-> ComputeFlags () ));
1907
1888
__ Push (x3, x2, x1, x0);
1908
1889
__ CallRuntime (Runtime::kCreateArrayLiteral , 4 );
1909
1890
} else {
@@ -1913,6 +1894,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1913
1894
PrepareForBailoutForId (expr->CreateLiteralId (), TOS_REG);
1914
1895
1915
1896
bool result_saved = false ; // Is the result saved to the stack?
1897
+ ZoneList<Expression*>* subexprs = expr->values ();
1898
+ int length = subexprs->length ();
1916
1899
1917
1900
// Emit code to evaluate all the non-constant subexpressions and to store
1918
1901
// them into the newly cloned array.
@@ -1929,7 +1912,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1929
1912
}
1930
1913
VisitForAccumulatorValue (subexpr);
1931
1914
1932
- if (IsFastObjectElementsKind (constant_elements_kind) ) {
1915
+ if (has_fast_elements ) {
1933
1916
int offset = FixedArray::kHeaderSize + (i * kPointerSize );
1934
1917
__ Peek (x6, kPointerSize ); // Copy of array literal.
1935
1918
__ Ldr (x1, FieldMemOperand (x6, JSObject::kElementsOffset ));
0 commit comments