Browse Source

deps: update V8 to 4.2.77.21

Picks up the latest patch-release on the V8 4.2 branch.
https://codereview.chromium.org/1156323004

PR-URL: https://github.com/nodejs/io.js/issues/2238
Fixes: https://github.com/nodejs/io.js/issues/2235
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
v4.0.0-rc
Ali Ijaz Sheikh 10 years ago
parent
commit
0a7bf81d2f
  1. 2
      deps/v8/include/v8-version.h
  2. 33
      deps/v8/src/arm/full-codegen-arm.cc
  3. 37
      deps/v8/src/arm64/full-codegen-arm64.cc
  4. 1
      deps/v8/src/ast.cc
  5. 24
      deps/v8/src/ast.h
  6. 4
      deps/v8/src/compiler/ast-graph-builder.cc
  7. 21
      deps/v8/src/full-codegen.cc
  8. 5
      deps/v8/src/full-codegen.h
  9. 13
      deps/v8/src/hydrogen.cc
  10. 38
      deps/v8/src/ia32/full-codegen-ia32.cc
  11. 36
      deps/v8/src/mips/full-codegen-mips.cc
  12. 36
      deps/v8/src/mips64/full-codegen-mips64.cc
  13. 31
      deps/v8/src/ppc/full-codegen-ppc.cc
  14. 3
      deps/v8/src/runtime/runtime-literals.cc
  15. 35
      deps/v8/src/x64/full-codegen-x64.cc

2
deps/v8/include/v8-version.h

@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 4 #define V8_MAJOR_VERSION 4
#define V8_MINOR_VERSION 2 #define V8_MINOR_VERSION 2
#define V8_BUILD_NUMBER 77 #define V8_BUILD_NUMBER 77
#define V8_PATCH_LEVEL 20 #define V8_PATCH_LEVEL 21
// Use 1 for candidates and 0 otherwise. // Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.) // (Boolean macro values are not supported by all preprocessors.)

33
deps/v8/src/arm/full-codegen-arm.cc

@ -1691,21 +1691,13 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
__ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); __ mov(r2, Operand(Smi::FromInt(expr->literal_index())));
__ mov(r1, Operand(constant_properties)); __ mov(r1, Operand(constant_properties));
int flags = expr->fast_elements() int flags = expr->ComputeFlags();
? ObjectLiteral::kFastElements
: ObjectLiteral::kNoFlags;
flags |= expr->has_function()
? ObjectLiteral::kHasFunction
: ObjectLiteral::kNoFlags;
__ mov(r0, Operand(Smi::FromInt(flags))); __ mov(r0, Operand(Smi::FromInt(flags)));
int properties_count = constant_properties->length() / 2; if (MustCreateObjectLiteralWithRuntime(expr)) {
if (expr->may_store_doubles() || expr->depth() > 1 ||
masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements ||
properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
__ Push(r3, r2, r1, r0); __ Push(r3, r2, r1, r0);
__ CallRuntime(Runtime::kCreateObjectLiteral, 4); __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
} else { } else {
FastCloneShallowObjectStub stub(isolate(), properties_count); FastCloneShallowObjectStub stub(isolate(), expr->properties_count());
__ CallStub(&stub); __ CallStub(&stub);
} }
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
@ -1897,17 +1889,10 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
Comment cmnt(masm_, "[ ArrayLiteral"); Comment cmnt(masm_, "[ ArrayLiteral");
expr->BuildConstantElements(isolate()); expr->BuildConstantElements(isolate());
int flags = expr->depth() == 1
? ArrayLiteral::kShallowElements
: ArrayLiteral::kNoFlags;
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
Handle<FixedArray> constant_elements = expr->constant_elements(); Handle<FixedArray> constant_elements = expr->constant_elements();
DCHECK_EQ(2, constant_elements->length()); bool has_fast_elements =
ElementsKind constant_elements_kind = IsFastObjectElementsKind(expr->constant_elements_kind());
static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind);
Handle<FixedArrayBase> constant_elements_values( Handle<FixedArrayBase> constant_elements_values(
FixedArrayBase::cast(constant_elements->get(1))); FixedArrayBase::cast(constant_elements->get(1)));
@ -1922,8 +1907,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
__ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
__ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); __ mov(r2, Operand(Smi::FromInt(expr->literal_index())));
__ mov(r1, Operand(constant_elements)); __ mov(r1, Operand(constant_elements));
if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { if (MustCreateArrayLiteralWithRuntime(expr)) {
__ mov(r0, Operand(Smi::FromInt(flags))); __ mov(r0, Operand(Smi::FromInt(expr->ComputeFlags())));
__ Push(r3, r2, r1, r0); __ Push(r3, r2, r1, r0);
__ CallRuntime(Runtime::kCreateArrayLiteral, 4); __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
} else { } else {
@ -1933,6 +1918,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
bool result_saved = false; // Is the result saved to the stack? bool result_saved = false; // Is the result saved to the stack?
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
// Emit code to evaluate all the non-constant subexpressions and to store // Emit code to evaluate all the non-constant subexpressions and to store
// them into the newly cloned array. // them into the newly cloned array.
@ -1949,7 +1936,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
} }
VisitForAccumulatorValue(subexpr); VisitForAccumulatorValue(subexpr);
if (IsFastObjectElementsKind(constant_elements_kind)) { if (has_fast_elements) {
int offset = FixedArray::kHeaderSize + (i * kPointerSize); int offset = FixedArray::kHeaderSize + (i * kPointerSize);
__ ldr(r6, MemOperand(sp, kPointerSize)); // Copy of array literal. __ ldr(r6, MemOperand(sp, kPointerSize)); // Copy of array literal.
__ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset)); __ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset));

37
deps/v8/src/arm64/full-codegen-arm64.cc

@ -1670,23 +1670,13 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset));
__ Mov(x2, Smi::FromInt(expr->literal_index())); __ Mov(x2, Smi::FromInt(expr->literal_index()));
__ Mov(x1, Operand(constant_properties)); __ Mov(x1, Operand(constant_properties));
int flags = expr->fast_elements() int flags = expr->ComputeFlags();
? ObjectLiteral::kFastElements
: ObjectLiteral::kNoFlags;
flags |= expr->has_function()
? ObjectLiteral::kHasFunction
: ObjectLiteral::kNoFlags;
__ Mov(x0, Smi::FromInt(flags)); __ Mov(x0, Smi::FromInt(flags));
int properties_count = constant_properties->length() / 2; if (MustCreateObjectLiteralWithRuntime(expr)) {
const int max_cloned_properties =
FastCloneShallowObjectStub::kMaximumClonedProperties;
if (expr->may_store_doubles() || expr->depth() > 1 ||
masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements ||
properties_count > max_cloned_properties) {
__ Push(x3, x2, x1, x0); __ Push(x3, x2, x1, x0);
__ CallRuntime(Runtime::kCreateObjectLiteral, 4); __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
} else { } else {
FastCloneShallowObjectStub stub(isolate(), properties_count); FastCloneShallowObjectStub stub(isolate(), expr->properties_count());
__ CallStub(&stub); __ CallStub(&stub);
} }
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
@ -1878,18 +1868,9 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
Comment cmnt(masm_, "[ ArrayLiteral"); Comment cmnt(masm_, "[ ArrayLiteral");
expr->BuildConstantElements(isolate()); expr->BuildConstantElements(isolate());
int flags = (expr->depth() == 1) ? ArrayLiteral::kShallowElements
: ArrayLiteral::kNoFlags;
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
Handle<FixedArray> constant_elements = expr->constant_elements(); Handle<FixedArray> constant_elements = expr->constant_elements();
DCHECK_EQ(2, constant_elements->length()); bool has_fast_elements =
ElementsKind constant_elements_kind = IsFastObjectElementsKind(expr->constant_elements_kind());
static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind);
Handle<FixedArrayBase> constant_elements_values(
FixedArrayBase::cast(constant_elements->get(1)));
AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE;
if (has_fast_elements && !FLAG_allocation_site_pretenuring) { if (has_fast_elements && !FLAG_allocation_site_pretenuring) {
@ -1902,8 +1883,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
__ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset));
__ Mov(x2, Smi::FromInt(expr->literal_index())); __ Mov(x2, Smi::FromInt(expr->literal_index()));
__ Mov(x1, Operand(constant_elements)); __ Mov(x1, Operand(constant_elements));
if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { if (MustCreateArrayLiteralWithRuntime(expr)) {
__ Mov(x0, Smi::FromInt(flags)); __ Mov(x0, Smi::FromInt(expr->ComputeFlags()));
__ Push(x3, x2, x1, x0); __ Push(x3, x2, x1, x0);
__ CallRuntime(Runtime::kCreateArrayLiteral, 4); __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
} else { } else {
@ -1913,6 +1894,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
bool result_saved = false; // Is the result saved to the stack? bool result_saved = false; // Is the result saved to the stack?
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
// Emit code to evaluate all the non-constant subexpressions and to store // Emit code to evaluate all the non-constant subexpressions and to store
// them into the newly cloned array. // them into the newly cloned array.
@ -1929,7 +1912,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
} }
VisitForAccumulatorValue(subexpr); VisitForAccumulatorValue(subexpr);
if (IsFastObjectElementsKind(constant_elements_kind)) { if (has_fast_elements) {
int offset = FixedArray::kHeaderSize + (i * kPointerSize); int offset = FixedArray::kHeaderSize + (i * kPointerSize);
__ Peek(x6, kPointerSize); // Copy of array literal. __ Peek(x6, kPointerSize); // Copy of array literal.
__ Ldr(x1, FieldMemOperand(x6, JSObject::kElementsOffset)); __ Ldr(x1, FieldMemOperand(x6, JSObject::kElementsOffset));

1
deps/v8/src/ast.cc

@ -334,6 +334,7 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
constant_properties_ = constant_properties; constant_properties_ = constant_properties;
fast_elements_ = fast_elements_ =
(max_element_index <= 32) || ((2 * elements) >= max_element_index); (max_element_index <= 32) || ((2 * elements) >= max_element_index);
has_elements_ = elements > 0;
set_is_simple(is_simple); set_is_simple(is_simple);
set_depth(depth_acc); set_depth(depth_acc);
} }

24
deps/v8/src/ast.h

@ -1457,10 +1457,12 @@ class ObjectLiteral FINAL : public MaterializedLiteral {
Handle<FixedArray> constant_properties() const { Handle<FixedArray> constant_properties() const {
return constant_properties_; return constant_properties_;
} }
int properties_count() const { return constant_properties_->length() / 2; }
ZoneList<Property*>* properties() const { return properties_; } ZoneList<Property*>* properties() const { return properties_; }
bool fast_elements() const { return fast_elements_; } bool fast_elements() const { return fast_elements_; }
bool may_store_doubles() const { return may_store_doubles_; } bool may_store_doubles() const { return may_store_doubles_; }
bool has_function() const { return has_function_; } bool has_function() const { return has_function_; }
bool has_elements() const { return has_elements_; }
// Decide if a property should be in the object boilerplate. // Decide if a property should be in the object boilerplate.
static bool IsBoilerplateProperty(Property* property); static bool IsBoilerplateProperty(Property* property);
@ -1474,16 +1476,20 @@ class ObjectLiteral FINAL : public MaterializedLiteral {
void CalculateEmitStore(Zone* zone); void CalculateEmitStore(Zone* zone);
// Assemble bitfield of flags for the CreateObjectLiteral helper. // Assemble bitfield of flags for the CreateObjectLiteral helper.
int ComputeFlags() const { int ComputeFlags(bool disable_mementos = false) const {
int flags = fast_elements() ? kFastElements : kNoFlags; int flags = fast_elements() ? kFastElements : kNoFlags;
flags |= has_function() ? kHasFunction : kNoFlags; flags |= has_function() ? kHasFunction : kNoFlags;
if (disable_mementos) {
flags |= kDisableMementos;
}
return flags; return flags;
} }
enum Flags { enum Flags {
kNoFlags = 0, kNoFlags = 0,
kFastElements = 1, kFastElements = 1,
kHasFunction = 1 << 1 kHasFunction = 1 << 1,
kDisableMementos = 1 << 2
}; };
struct Accessors: public ZoneObject { struct Accessors: public ZoneObject {
@ -1508,6 +1514,7 @@ class ObjectLiteral FINAL : public MaterializedLiteral {
properties_(properties), properties_(properties),
boilerplate_properties_(boilerplate_properties), boilerplate_properties_(boilerplate_properties),
fast_elements_(false), fast_elements_(false),
has_elements_(false),
may_store_doubles_(false), may_store_doubles_(false),
has_function_(has_function) {} has_function_(has_function) {}
static int parent_num_ids() { return MaterializedLiteral::num_ids(); } static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
@ -1518,6 +1525,7 @@ class ObjectLiteral FINAL : public MaterializedLiteral {
ZoneList<Property*>* properties_; ZoneList<Property*>* properties_;
int boilerplate_properties_; int boilerplate_properties_;
bool fast_elements_; bool fast_elements_;
bool has_elements_;
bool may_store_doubles_; bool may_store_doubles_;
bool has_function_; bool has_function_;
}; };
@ -1553,6 +1561,12 @@ class ArrayLiteral FINAL : public MaterializedLiteral {
DECLARE_NODE_TYPE(ArrayLiteral) DECLARE_NODE_TYPE(ArrayLiteral)
Handle<FixedArray> constant_elements() const { return constant_elements_; } Handle<FixedArray> constant_elements() const { return constant_elements_; }
ElementsKind constant_elements_kind() const {
DCHECK_EQ(2, constant_elements_->length());
return static_cast<ElementsKind>(
Smi::cast(constant_elements_->get(0))->value());
}
ZoneList<Expression*>* values() const { return values_; } ZoneList<Expression*>* values() const { return values_; }
BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); }
@ -1568,9 +1582,11 @@ class ArrayLiteral FINAL : public MaterializedLiteral {
void BuildConstantElements(Isolate* isolate); void BuildConstantElements(Isolate* isolate);
// Assemble bitfield of flags for the CreateArrayLiteral helper. // Assemble bitfield of flags for the CreateArrayLiteral helper.
int ComputeFlags() const { int ComputeFlags(bool disable_mementos = false) const {
int flags = depth() == 1 ? kShallowElements : kNoFlags; int flags = depth() == 1 ? kShallowElements : kNoFlags;
flags |= ArrayLiteral::kDisableMementos; if (disable_mementos) {
flags |= kDisableMementos;
}
return flags; return flags;
} }

4
deps/v8/src/compiler/ast-graph-builder.cc

@ -1464,7 +1464,7 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
BuildLoadObjectField(closure, JSFunction::kLiteralsOffset); BuildLoadObjectField(closure, JSFunction::kLiteralsOffset);
Node* literal_index = jsgraph()->Constant(expr->literal_index()); Node* literal_index = jsgraph()->Constant(expr->literal_index());
Node* constants = jsgraph()->Constant(expr->constant_properties()); Node* constants = jsgraph()->Constant(expr->constant_properties());
Node* flags = jsgraph()->Constant(expr->ComputeFlags()); Node* flags = jsgraph()->Constant(expr->ComputeFlags(true));
const Operator* op = const Operator* op =
javascript()->CallRuntime(Runtime::kCreateObjectLiteral, 4); javascript()->CallRuntime(Runtime::kCreateObjectLiteral, 4);
Node* literal = NewNode(op, literals_array, literal_index, constants, flags); Node* literal = NewNode(op, literals_array, literal_index, constants, flags);
@ -1656,7 +1656,7 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
BuildLoadObjectField(closure, JSFunction::kLiteralsOffset); BuildLoadObjectField(closure, JSFunction::kLiteralsOffset);
Node* literal_index = jsgraph()->Constant(expr->literal_index()); Node* literal_index = jsgraph()->Constant(expr->literal_index());
Node* constants = jsgraph()->Constant(expr->constant_elements()); Node* constants = jsgraph()->Constant(expr->constant_elements());
Node* flags = jsgraph()->Constant(expr->ComputeFlags()); Node* flags = jsgraph()->Constant(expr->ComputeFlags(true));
const Operator* op = const Operator* op =
javascript()->CallRuntime(Runtime::kCreateArrayLiteral, 4); javascript()->CallRuntime(Runtime::kCreateArrayLiteral, 4);
Node* literal = NewNode(op, literals_array, literal_index, constants, flags); Node* literal = NewNode(op, literals_array, literal_index, constants, flags);

21
deps/v8/src/full-codegen.cc

@ -415,6 +415,27 @@ void FullCodeGenerator::PopulateTypeFeedbackInfo(Handle<Code> code) {
} }
bool FullCodeGenerator::MustCreateObjectLiteralWithRuntime(
ObjectLiteral* expr) const {
// FastCloneShallowObjectStub doesn't copy elements, and object literals don't
// support copy-on-write (COW) elements for now.
// TODO(mvstanton): make object literals support COW elements.
return expr->may_store_doubles() || expr->depth() > 1 ||
masm()->serializer_enabled() ||
expr->ComputeFlags() != ObjectLiteral::kFastElements ||
expr->has_elements() ||
expr->properties_count() >
FastCloneShallowObjectStub::kMaximumClonedProperties;
}
bool FullCodeGenerator::MustCreateArrayLiteralWithRuntime(
ArrayLiteral* expr) const {
return expr->depth() > 1 ||
expr->values()->length() > JSObject::kInitialMaxFastElementArray;
}
void FullCodeGenerator::Initialize() { void FullCodeGenerator::Initialize() {
InitializeAstVisitor(info_->isolate(), info_->zone()); InitializeAstVisitor(info_->isolate(), info_->zone());
// The generation of debug code must match between the snapshot code and the // The generation of debug code must match between the snapshot code and the

5
deps/v8/src/full-codegen.h

@ -667,7 +667,7 @@ class FullCodeGenerator: public AstVisitor {
loop_depth_--; loop_depth_--;
} }
MacroAssembler* masm() { return masm_; } MacroAssembler* masm() const { return masm_; }
class ExpressionContext; class ExpressionContext;
const ExpressionContext* context() { return context_; } const ExpressionContext* context() { return context_; }
@ -711,6 +711,9 @@ class FullCodeGenerator: public AstVisitor {
void PopulateDeoptimizationData(Handle<Code> code); void PopulateDeoptimizationData(Handle<Code> code);
void PopulateTypeFeedbackInfo(Handle<Code> code); void PopulateTypeFeedbackInfo(Handle<Code> code);
bool MustCreateObjectLiteralWithRuntime(ObjectLiteral* expr) const;
bool MustCreateArrayLiteralWithRuntime(ArrayLiteral* expr) const;
Handle<FixedArray> handler_table() { return handler_table_; } Handle<FixedArray> handler_table() { return handler_table_; }
struct BailoutEntry { struct BailoutEntry {

13
deps/v8/src/hydrogen.cc

@ -5551,19 +5551,13 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
Handle<FixedArray> closure_literals(closure->literals(), isolate()); Handle<FixedArray> closure_literals(closure->literals(), isolate());
Handle<FixedArray> constant_properties = expr->constant_properties(); Handle<FixedArray> constant_properties = expr->constant_properties();
int literal_index = expr->literal_index(); int literal_index = expr->literal_index();
int flags = expr->fast_elements() int flags = expr->ComputeFlags(true);
? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags;
flags |= expr->has_function()
? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags;
Add<HPushArguments>(Add<HConstant>(closure_literals), Add<HPushArguments>(Add<HConstant>(closure_literals),
Add<HConstant>(literal_index), Add<HConstant>(literal_index),
Add<HConstant>(constant_properties), Add<HConstant>(constant_properties),
Add<HConstant>(flags)); Add<HConstant>(flags));
// TODO(mvstanton): Add a flag to turn off creation of any
// AllocationMementos for this call: we are in crankshaft and should have
// learned enough about transition behavior to stop emitting mementos.
Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral; Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral;
literal = Add<HCallRuntime>(isolate()->factory()->empty_string(), literal = Add<HCallRuntime>(isolate()->factory()->empty_string(),
Runtime::FunctionForId(function_id), Runtime::FunctionForId(function_id),
@ -5722,10 +5716,7 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
// pass an empty fixed array to the runtime function instead. // pass an empty fixed array to the runtime function instead.
Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array();
int literal_index = expr->literal_index(); int literal_index = expr->literal_index();
int flags = expr->depth() == 1 int flags = expr->ComputeFlags(true);
? ArrayLiteral::kShallowElements
: ArrayLiteral::kNoFlags;
flags |= ArrayLiteral::kDisableMementos;
Add<HPushArguments>(Add<HConstant>(literals), Add<HPushArguments>(Add<HConstant>(literals),
Add<HConstant>(literal_index), Add<HConstant>(literal_index),

38
deps/v8/src/ia32/full-codegen-ia32.cc

@ -1614,17 +1614,10 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
expr->BuildConstantProperties(isolate()); expr->BuildConstantProperties(isolate());
Handle<FixedArray> constant_properties = expr->constant_properties(); Handle<FixedArray> constant_properties = expr->constant_properties();
int flags = expr->fast_elements() int flags = expr->ComputeFlags();
? ObjectLiteral::kFastElements // If any of the keys would store to the elements array, then we shouldn't
: ObjectLiteral::kNoFlags; // allow it.
flags |= expr->has_function() if (MustCreateObjectLiteralWithRuntime(expr)) {
? ObjectLiteral::kHasFunction
: ObjectLiteral::kNoFlags;
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) {
__ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
__ push(FieldOperand(edi, JSFunction::kLiteralsOffset)); __ push(FieldOperand(edi, JSFunction::kLiteralsOffset));
__ push(Immediate(Smi::FromInt(expr->literal_index()))); __ push(Immediate(Smi::FromInt(expr->literal_index())));
@ -1637,7 +1630,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index())));
__ mov(ecx, Immediate(constant_properties)); __ mov(ecx, Immediate(constant_properties));
__ mov(edx, Immediate(Smi::FromInt(flags))); __ mov(edx, Immediate(Smi::FromInt(flags)));
FastCloneShallowObjectStub stub(isolate(), properties_count); FastCloneShallowObjectStub stub(isolate(), expr->properties_count());
__ CallStub(&stub); __ CallStub(&stub);
} }
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
@ -1816,20 +1809,9 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
Comment cmnt(masm_, "[ ArrayLiteral"); Comment cmnt(masm_, "[ ArrayLiteral");
expr->BuildConstantElements(isolate()); expr->BuildConstantElements(isolate());
int flags = expr->depth() == 1
? ArrayLiteral::kShallowElements
: ArrayLiteral::kNoFlags;
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
Handle<FixedArray> constant_elements = expr->constant_elements(); Handle<FixedArray> constant_elements = expr->constant_elements();
DCHECK_EQ(2, constant_elements->length());
ElementsKind constant_elements_kind =
static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
bool has_constant_fast_elements = bool has_constant_fast_elements =
IsFastObjectElementsKind(constant_elements_kind); IsFastObjectElementsKind(expr->constant_elements_kind());
Handle<FixedArrayBase> constant_elements_values(
FixedArrayBase::cast(constant_elements->get(1)));
AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE;
if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) { if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) {
@ -1838,12 +1820,12 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
} }
if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { if (MustCreateArrayLiteralWithRuntime(expr)) {
__ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
__ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset));
__ push(Immediate(Smi::FromInt(expr->literal_index()))); __ push(Immediate(Smi::FromInt(expr->literal_index())));
__ push(Immediate(constant_elements)); __ push(Immediate(constant_elements));
__ push(Immediate(Smi::FromInt(flags))); __ push(Immediate(Smi::FromInt(expr->ComputeFlags())));
__ CallRuntime(Runtime::kCreateArrayLiteral, 4); __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
} else { } else {
__ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
@ -1856,6 +1838,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
bool result_saved = false; // Is the result saved to the stack? bool result_saved = false; // Is the result saved to the stack?
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
// Emit code to evaluate all the non-constant subexpressions and to store // Emit code to evaluate all the non-constant subexpressions and to store
// them into the newly cloned array. // them into the newly cloned array.
@ -1872,7 +1856,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
} }
VisitForAccumulatorValue(subexpr); VisitForAccumulatorValue(subexpr);
if (IsFastObjectElementsKind(constant_elements_kind)) { if (has_constant_fast_elements) {
// Fast-case array literal with ElementsKind of FAST_*_ELEMENTS, they // Fast-case array literal with ElementsKind of FAST_*_ELEMENTS, they
// cannot transition and don't need to call the runtime stub. // cannot transition and don't need to call the runtime stub.
int offset = FixedArray::kHeaderSize + (i * kPointerSize); int offset = FixedArray::kHeaderSize + (i * kPointerSize);

36
deps/v8/src/mips/full-codegen-mips.cc

@ -1677,21 +1677,12 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset));
__ li(a2, Operand(Smi::FromInt(expr->literal_index()))); __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
__ li(a1, Operand(constant_properties)); __ li(a1, Operand(constant_properties));
int flags = expr->fast_elements() __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags())));
? ObjectLiteral::kFastElements if (MustCreateObjectLiteralWithRuntime(expr)) {
: 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) {
__ Push(a3, a2, a1, a0); __ Push(a3, a2, a1, a0);
__ CallRuntime(Runtime::kCreateObjectLiteral, 4); __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
} else { } else {
FastCloneShallowObjectStub stub(isolate(), properties_count); FastCloneShallowObjectStub stub(isolate(), expr->properties_count());
__ CallStub(&stub); __ CallStub(&stub);
} }
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
@ -1883,21 +1874,10 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
Comment cmnt(masm_, "[ ArrayLiteral"); Comment cmnt(masm_, "[ ArrayLiteral");
expr->BuildConstantElements(isolate()); expr->BuildConstantElements(isolate());
int flags = expr->depth() == 1
? ArrayLiteral::kShallowElements
: ArrayLiteral::kNoFlags;
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
Handle<FixedArray> constant_elements = expr->constant_elements(); Handle<FixedArray> constant_elements = expr->constant_elements();
DCHECK_EQ(2, constant_elements->length());
ElementsKind constant_elements_kind =
static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
bool has_fast_elements = bool has_fast_elements =
IsFastObjectElementsKind(constant_elements_kind); IsFastObjectElementsKind(expr->constant_elements_kind());
Handle<FixedArrayBase> constant_elements_values(
FixedArrayBase::cast(constant_elements->get(1)));
AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE;
if (has_fast_elements && !FLAG_allocation_site_pretenuring) { if (has_fast_elements && !FLAG_allocation_site_pretenuring) {
@ -1911,8 +1891,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
__ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset));
__ li(a2, Operand(Smi::FromInt(expr->literal_index()))); __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
__ li(a1, Operand(constant_elements)); __ li(a1, Operand(constant_elements));
if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { if (MustCreateArrayLiteralWithRuntime(expr)) {
__ li(a0, Operand(Smi::FromInt(flags))); __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags())));
__ Push(a3, a2, a1, a0); __ Push(a3, a2, a1, a0);
__ CallRuntime(Runtime::kCreateArrayLiteral, 4); __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
} else { } else {
@ -1922,6 +1902,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
bool result_saved = false; // Is the result saved to the stack? bool result_saved = false; // Is the result saved to the stack?
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
// Emit code to evaluate all the non-constant subexpressions and to store // Emit code to evaluate all the non-constant subexpressions and to store
// them into the newly cloned array. // them into the newly cloned array.
@ -1939,7 +1921,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
VisitForAccumulatorValue(subexpr); VisitForAccumulatorValue(subexpr);
if (IsFastObjectElementsKind(constant_elements_kind)) { if (has_fast_elements) {
int offset = FixedArray::kHeaderSize + (i * kPointerSize); int offset = FixedArray::kHeaderSize + (i * kPointerSize);
__ lw(t2, MemOperand(sp, kPointerSize)); // Copy of array literal. __ lw(t2, MemOperand(sp, kPointerSize)); // Copy of array literal.
__ lw(a1, FieldMemOperand(t2, JSObject::kElementsOffset)); __ lw(a1, FieldMemOperand(t2, JSObject::kElementsOffset));

36
deps/v8/src/mips64/full-codegen-mips64.cc

@ -1675,21 +1675,12 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ ld(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); __ ld(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset));
__ li(a2, Operand(Smi::FromInt(expr->literal_index()))); __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
__ li(a1, Operand(constant_properties)); __ li(a1, Operand(constant_properties));
int flags = expr->fast_elements() __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags())));
? ObjectLiteral::kFastElements if (MustCreateObjectLiteralWithRuntime(expr)) {
: 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) {
__ Push(a3, a2, a1, a0); __ Push(a3, a2, a1, a0);
__ CallRuntime(Runtime::kCreateObjectLiteral, 4); __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
} else { } else {
FastCloneShallowObjectStub stub(isolate(), properties_count); FastCloneShallowObjectStub stub(isolate(), expr->properties_count());
__ CallStub(&stub); __ CallStub(&stub);
} }
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
@ -1881,21 +1872,10 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
Comment cmnt(masm_, "[ ArrayLiteral"); Comment cmnt(masm_, "[ ArrayLiteral");
expr->BuildConstantElements(isolate()); expr->BuildConstantElements(isolate());
int flags = expr->depth() == 1
? ArrayLiteral::kShallowElements
: ArrayLiteral::kNoFlags;
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
Handle<FixedArray> constant_elements = expr->constant_elements(); Handle<FixedArray> constant_elements = expr->constant_elements();
DCHECK_EQ(2, constant_elements->length());
ElementsKind constant_elements_kind =
static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
bool has_fast_elements = bool has_fast_elements =
IsFastObjectElementsKind(constant_elements_kind); IsFastObjectElementsKind(expr->constant_elements_kind());
Handle<FixedArrayBase> constant_elements_values(
FixedArrayBase::cast(constant_elements->get(1)));
AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE;
if (has_fast_elements && !FLAG_allocation_site_pretenuring) { if (has_fast_elements && !FLAG_allocation_site_pretenuring) {
@ -1909,8 +1889,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
__ ld(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); __ ld(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset));
__ li(a2, Operand(Smi::FromInt(expr->literal_index()))); __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
__ li(a1, Operand(constant_elements)); __ li(a1, Operand(constant_elements));
if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { if (MustCreateArrayLiteralWithRuntime(expr)) {
__ li(a0, Operand(Smi::FromInt(flags))); __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags())));
__ Push(a3, a2, a1, a0); __ Push(a3, a2, a1, a0);
__ CallRuntime(Runtime::kCreateArrayLiteral, 4); __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
} else { } else {
@ -1920,6 +1900,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
bool result_saved = false; // Is the result saved to the stack? bool result_saved = false; // Is the result saved to the stack?
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
// Emit code to evaluate all the non-constant subexpressions and to store // Emit code to evaluate all the non-constant subexpressions and to store
// them into the newly cloned array. // them into the newly cloned array.
@ -1937,7 +1919,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
VisitForAccumulatorValue(subexpr); VisitForAccumulatorValue(subexpr);
if (IsFastObjectElementsKind(constant_elements_kind)) { if (has_fast_elements) {
int offset = FixedArray::kHeaderSize + (i * kPointerSize); int offset = FixedArray::kHeaderSize + (i * kPointerSize);
__ ld(a6, MemOperand(sp, kPointerSize)); // Copy of array literal. __ ld(a6, MemOperand(sp, kPointerSize)); // Copy of array literal.
__ ld(a1, FieldMemOperand(a6, JSObject::kElementsOffset)); __ ld(a1, FieldMemOperand(a6, JSObject::kElementsOffset));

31
deps/v8/src/ppc/full-codegen-ppc.cc

@ -1619,19 +1619,13 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ LoadP(r6, FieldMemOperand(r6, JSFunction::kLiteralsOffset)); __ LoadP(r6, FieldMemOperand(r6, JSFunction::kLiteralsOffset));
__ LoadSmiLiteral(r5, Smi::FromInt(expr->literal_index())); __ LoadSmiLiteral(r5, Smi::FromInt(expr->literal_index()));
__ mov(r4, Operand(constant_properties)); __ mov(r4, Operand(constant_properties));
int flags = expr->fast_elements() ? ObjectLiteral::kFastElements int flags = expr->ComputeFlags();
: ObjectLiteral::kNoFlags;
flags |= expr->has_function() ? ObjectLiteral::kHasFunction
: ObjectLiteral::kNoFlags;
__ LoadSmiLiteral(r3, Smi::FromInt(flags)); __ LoadSmiLiteral(r3, Smi::FromInt(flags));
int properties_count = constant_properties->length() / 2; if (MustCreateObjectLiteralWithRuntime(expr)) {
if (expr->may_store_doubles() || expr->depth() > 1 ||
masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements ||
properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
__ Push(r6, r5, r4, r3); __ Push(r6, r5, r4, r3);
__ CallRuntime(Runtime::kCreateObjectLiteral, 4); __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
} else { } else {
FastCloneShallowObjectStub stub(isolate(), properties_count); FastCloneShallowObjectStub stub(isolate(), expr->properties_count());
__ CallStub(&stub); __ CallStub(&stub);
} }
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
@ -1821,16 +1815,9 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
Comment cmnt(masm_, "[ ArrayLiteral"); Comment cmnt(masm_, "[ ArrayLiteral");
expr->BuildConstantElements(isolate()); expr->BuildConstantElements(isolate());
int flags = expr->depth() == 1 ? ArrayLiteral::kShallowElements
: ArrayLiteral::kNoFlags;
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
Handle<FixedArray> constant_elements = expr->constant_elements(); Handle<FixedArray> constant_elements = expr->constant_elements();
DCHECK_EQ(2, constant_elements->length()); bool has_fast_elements =
ElementsKind constant_elements_kind = IsFastObjectElementsKind(expr->constant_elements_kind());
static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind);
Handle<FixedArrayBase> constant_elements_values( Handle<FixedArrayBase> constant_elements_values(
FixedArrayBase::cast(constant_elements->get(1))); FixedArrayBase::cast(constant_elements->get(1)));
@ -1845,8 +1832,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
__ LoadP(r6, FieldMemOperand(r6, JSFunction::kLiteralsOffset)); __ LoadP(r6, FieldMemOperand(r6, JSFunction::kLiteralsOffset));
__ LoadSmiLiteral(r5, Smi::FromInt(expr->literal_index())); __ LoadSmiLiteral(r5, Smi::FromInt(expr->literal_index()));
__ mov(r4, Operand(constant_elements)); __ mov(r4, Operand(constant_elements));
if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { if (MustCreateArrayLiteralWithRuntime(expr)) {
__ LoadSmiLiteral(r3, Smi::FromInt(flags)); __ LoadSmiLiteral(r3, Smi::FromInt(expr->ComputeFlags()));
__ Push(r6, r5, r4, r3); __ Push(r6, r5, r4, r3);
__ CallRuntime(Runtime::kCreateArrayLiteral, 4); __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
} else { } else {
@ -1856,6 +1843,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
bool result_saved = false; // Is the result saved to the stack? bool result_saved = false; // Is the result saved to the stack?
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
// Emit code to evaluate all the non-constant subexpressions and to store // Emit code to evaluate all the non-constant subexpressions and to store
// them into the newly cloned array. // them into the newly cloned array.
@ -1872,7 +1861,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
} }
VisitForAccumulatorValue(subexpr); VisitForAccumulatorValue(subexpr);
if (IsFastObjectElementsKind(constant_elements_kind)) { if (has_fast_elements) {
int offset = FixedArray::kHeaderSize + (i * kPointerSize); int offset = FixedArray::kHeaderSize + (i * kPointerSize);
__ LoadP(r8, MemOperand(sp, kPointerSize)); // Copy of array literal. __ LoadP(r8, MemOperand(sp, kPointerSize)); // Copy of array literal.
__ LoadP(r4, FieldMemOperand(r8, JSObject::kElementsOffset)); __ LoadP(r4, FieldMemOperand(r8, JSObject::kElementsOffset));

3
deps/v8/src/runtime/runtime-literals.cc

@ -245,6 +245,7 @@ RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) {
CONVERT_SMI_ARG_CHECKED(flags, 3); CONVERT_SMI_ARG_CHECKED(flags, 3);
bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
bool enable_mementos = (flags & ObjectLiteral::kDisableMementos) == 0;
RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length()); RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length());
@ -275,7 +276,7 @@ RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) {
Handle<JSObject>(JSObject::cast(site->transition_info()), isolate); Handle<JSObject>(JSObject::cast(site->transition_info()), isolate);
} }
AllocationSiteUsageContext usage_context(isolate, site, true); AllocationSiteUsageContext usage_context(isolate, site, enable_mementos);
usage_context.EnterNewScope(); usage_context.EnterNewScope();
MaybeHandle<Object> maybe_copy = MaybeHandle<Object> maybe_copy =
JSObject::DeepCopy(boilerplate, &usage_context); JSObject::DeepCopy(boilerplate, &usage_context);

35
deps/v8/src/x64/full-codegen-x64.cc

@ -1650,16 +1650,8 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
expr->BuildConstantProperties(isolate()); expr->BuildConstantProperties(isolate());
Handle<FixedArray> constant_properties = expr->constant_properties(); Handle<FixedArray> constant_properties = expr->constant_properties();
int flags = expr->fast_elements() int flags = expr->ComputeFlags();
? ObjectLiteral::kFastElements if (MustCreateObjectLiteralWithRuntime(expr)) {
: ObjectLiteral::kNoFlags;
flags |= expr->has_function()
? ObjectLiteral::kHasFunction
: ObjectLiteral::kNoFlags;
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) {
__ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); __ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
__ Push(FieldOperand(rdi, JSFunction::kLiteralsOffset)); __ Push(FieldOperand(rdi, JSFunction::kLiteralsOffset));
__ Push(Smi::FromInt(expr->literal_index())); __ Push(Smi::FromInt(expr->literal_index()));
@ -1672,7 +1664,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ Move(rbx, Smi::FromInt(expr->literal_index())); __ Move(rbx, Smi::FromInt(expr->literal_index()));
__ Move(rcx, constant_properties); __ Move(rcx, constant_properties);
__ Move(rdx, Smi::FromInt(flags)); __ Move(rdx, Smi::FromInt(flags));
FastCloneShallowObjectStub stub(isolate(), properties_count); FastCloneShallowObjectStub stub(isolate(), expr->properties_count());
__ CallStub(&stub); __ CallStub(&stub);
} }
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
@ -1851,20 +1843,9 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
Comment cmnt(masm_, "[ ArrayLiteral"); Comment cmnt(masm_, "[ ArrayLiteral");
expr->BuildConstantElements(isolate()); expr->BuildConstantElements(isolate());
int flags = expr->depth() == 1
? ArrayLiteral::kShallowElements
: ArrayLiteral::kNoFlags;
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
Handle<FixedArray> constant_elements = expr->constant_elements(); Handle<FixedArray> constant_elements = expr->constant_elements();
DCHECK_EQ(2, constant_elements->length());
ElementsKind constant_elements_kind =
static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
bool has_constant_fast_elements = bool has_constant_fast_elements =
IsFastObjectElementsKind(constant_elements_kind); IsFastObjectElementsKind(expr->constant_elements_kind());
Handle<FixedArrayBase> constant_elements_values(
FixedArrayBase::cast(constant_elements->get(1)));
AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE;
if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) { if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) {
@ -1873,12 +1854,12 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
} }
if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { if (MustCreateArrayLiteralWithRuntime(expr)) {
__ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
__ Push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); __ Push(FieldOperand(rbx, JSFunction::kLiteralsOffset));
__ Push(Smi::FromInt(expr->literal_index())); __ Push(Smi::FromInt(expr->literal_index()));
__ Push(constant_elements); __ Push(constant_elements);
__ Push(Smi::FromInt(flags)); __ Push(Smi::FromInt(expr->ComputeFlags()));
__ CallRuntime(Runtime::kCreateArrayLiteral, 4); __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
} else { } else {
__ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
@ -1891,6 +1872,8 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
bool result_saved = false; // Is the result saved to the stack? bool result_saved = false; // Is the result saved to the stack?
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
// Emit code to evaluate all the non-constant subexpressions and to store // Emit code to evaluate all the non-constant subexpressions and to store
// them into the newly cloned array. // them into the newly cloned array.
@ -1907,7 +1890,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
} }
VisitForAccumulatorValue(subexpr); VisitForAccumulatorValue(subexpr);
if (IsFastObjectElementsKind(constant_elements_kind)) { if (has_constant_fast_elements) {
// Fast-case array literal with ElementsKind of FAST_*_ELEMENTS, they // Fast-case array literal with ElementsKind of FAST_*_ELEMENTS, they
// cannot transition and don't need to call the runtime stub. // cannot transition and don't need to call the runtime stub.
int offset = FixedArray::kHeaderSize + (i * kPointerSize); int offset = FixedArray::kHeaderSize + (i * kPointerSize);

Loading…
Cancel
Save