Commit dbaafb76 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[literals] No longer use a FeedbackVectorSlot for the empty object literal

Bug: v8:6211
Change-Id: I0f15c59b7b786ab327e4ab548523095dd85ba83e
Reviewed-on: https://chromium-review.googlesource.com/637835Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47650}
parent 8fb5000e
...@@ -780,8 +780,6 @@ TF_BUILTIN(FastCloneShallowObject, ConstructorBuiltinsAssembler) { ...@@ -780,8 +780,6 @@ TF_BUILTIN(FastCloneShallowObject, ConstructorBuiltinsAssembler) {
// Used by the CreateEmptyObjectLiteral stub and bytecode. // Used by the CreateEmptyObjectLiteral stub and bytecode.
Node* ConstructorBuiltinsAssembler::EmitCreateEmptyObjectLiteral( Node* ConstructorBuiltinsAssembler::EmitCreateEmptyObjectLiteral(
Node* context) { Node* context) {
// TODO(cbruni): check whether we have to enable pretenuring support again for
// the empty object literal.
Node* native_context = LoadNativeContext(context); Node* native_context = LoadNativeContext(context);
Node* object_function = Node* object_function =
LoadContextElement(native_context, Context::OBJECT_FUNCTION_INDEX); LoadContextElement(native_context, Context::OBJECT_FUNCTION_INDEX);
...@@ -796,9 +794,6 @@ Node* ConstructorBuiltinsAssembler::EmitCreateEmptyObjectLiteral( ...@@ -796,9 +794,6 @@ Node* ConstructorBuiltinsAssembler::EmitCreateEmptyObjectLiteral(
} }
TF_BUILTIN(CreateEmptyObjectLiteral, ConstructorBuiltinsAssembler) { TF_BUILTIN(CreateEmptyObjectLiteral, ConstructorBuiltinsAssembler) {
// TODO(cbruni): remove closure and literal_index paramters once it's clear
// whether we can live without pretenuring support for the empty object
// literal.
Node* context = Parameter(Descriptor::kContext); Node* context = Parameter(Descriptor::kContext);
Node* result = EmitCreateEmptyObjectLiteral(context); Node* result = EmitCreateEmptyObjectLiteral(context);
Return(result); Return(result);
......
...@@ -80,7 +80,7 @@ namespace internal { ...@@ -80,7 +80,7 @@ namespace internal {
TFC(FastCloneShallowArrayTrack, FastCloneShallowArray, 1) \ TFC(FastCloneShallowArrayTrack, FastCloneShallowArray, 1) \
TFC(FastCloneShallowArrayDontTrack, FastCloneShallowArray, 1) \ TFC(FastCloneShallowArrayDontTrack, FastCloneShallowArray, 1) \
TFS(CreateEmptyArrayLiteral, kClosure, kLiteralIndex) \ TFS(CreateEmptyArrayLiteral, kClosure, kLiteralIndex) \
TFS(CreateEmptyObjectLiteral, kClosure, kLiteralIndex) \ TFS(CreateEmptyObjectLiteral, kClosure) \
TFC(FastCloneShallowObject, FastCloneShallowObject, 1) \ TFC(FastCloneShallowObject, FastCloneShallowObject, 1) \
/* ES6 section 9.5.14 [[Construct]] ( argumentsList, newTarget) */ \ /* ES6 section 9.5.14 [[Construct]] ( argumentsList, newTarget) */ \
TFC(ConstructProxy, ConstructTrampoline, 1) \ TFC(ConstructProxy, ConstructTrampoline, 1) \
......
...@@ -1540,9 +1540,8 @@ void BytecodeGraphBuilder::VisitCreateObjectLiteral() { ...@@ -1540,9 +1540,8 @@ void BytecodeGraphBuilder::VisitCreateObjectLiteral() {
} }
void BytecodeGraphBuilder::VisitCreateEmptyObjectLiteral() { void BytecodeGraphBuilder::VisitCreateEmptyObjectLiteral() {
int literal_index = bytecode_iterator().GetIndexOperand(0); Node* literal =
Node* literal = NewNode(javascript()->CreateEmptyLiteralObject(literal_index), NewNode(javascript()->CreateEmptyLiteralObject(), GetFunctionClosure());
GetFunctionClosure());
environment()->BindAccumulator(literal); environment()->BindAccumulator(literal);
} }
......
...@@ -940,7 +940,7 @@ Reduction JSCreateLowering::ReduceJSCreateEmptyLiteralArray(Node* node) { ...@@ -940,7 +940,7 @@ Reduction JSCreateLowering::ReduceJSCreateEmptyLiteralArray(Node* node) {
return NoChange(); return NoChange();
} }
Reduction JSCreateLowering::ReduceNewObject(Node* node) { Reduction JSCreateLowering::ReduceJSCreateEmptyLiteralObject(Node* node) {
DCHECK_EQ(IrOpcode::kJSCreateEmptyLiteralObject, node->opcode()); DCHECK_EQ(IrOpcode::kJSCreateEmptyLiteralObject, node->opcode());
Node* effect = NodeProperties::GetEffectInput(node); Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
...@@ -971,21 +971,6 @@ Reduction JSCreateLowering::ReduceNewObject(Node* node) { ...@@ -971,21 +971,6 @@ Reduction JSCreateLowering::ReduceNewObject(Node* node) {
return Changed(node); return Changed(node);
} }
Reduction JSCreateLowering::ReduceJSCreateEmptyLiteralObject(Node* node) {
DCHECK_EQ(node->opcode(), IrOpcode::kJSCreateEmptyLiteralObject);
int literal_index = OpParameter<int>(node);
Handle<FeedbackVector> feedback_vector;
if (GetSpecializationFeedbackVector(node).ToHandle(&feedback_vector)) {
FeedbackSlot slot(FeedbackVector::ToSlot(literal_index));
Handle<Object> raw_site(feedback_vector->Get(slot), isolate());
// TODO(cbruni): remove once the empty object literal doesn't rely on the
// AllocationSite anymore.
DCHECK(!raw_site->IsAllocationSite());
return ReduceNewObject(node);
}
return NoChange();
}
Reduction JSCreateLowering::ReduceJSCreateLiteralRegExp(Node* node) { Reduction JSCreateLowering::ReduceJSCreateLiteralRegExp(Node* node) {
DCHECK(node->opcode() == IrOpcode::kJSCreateLiteralRegExp); DCHECK(node->opcode() == IrOpcode::kJSCreateLiteralRegExp);
CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
......
...@@ -67,7 +67,6 @@ class V8_EXPORT_PRIVATE JSCreateLowering final ...@@ -67,7 +67,6 @@ class V8_EXPORT_PRIVATE JSCreateLowering final
Handle<AllocationSite> site); Handle<AllocationSite> site);
Reduction ReduceNewArray(Node* node, std::vector<Node*> values, Reduction ReduceNewArray(Node* node, std::vector<Node*> values,
Handle<AllocationSite> site); Handle<AllocationSite> site);
Reduction ReduceNewObject(Node* node);
Node* AllocateArguments(Node* effect, Node* control, Node* frame_state); Node* AllocateArguments(Node* effect, Node* control, Node* frame_state);
Node* AllocateRestArguments(Node* effect, Node* control, Node* frame_state, Node* AllocateRestArguments(Node* effect, Node* control, Node* frame_state,
......
...@@ -507,8 +507,6 @@ void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) { ...@@ -507,8 +507,6 @@ void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
void JSGenericLowering::LowerJSCreateEmptyLiteralObject(Node* node) { void JSGenericLowering::LowerJSCreateEmptyLiteralObject(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node); CallDescriptor::Flags flags = FrameStateFlagForCall(node);
int literal_index = OpParameter<int>(node->op());
node->InsertInput(zone(), 1, jsgraph()->SmiConstant(literal_index));
Callable callable = Callable callable =
Builtins::CallableFor(isolate(), Builtins::kCreateEmptyObjectLiteral); Builtins::CallableFor(isolate(), Builtins::kCreateEmptyObjectLiteral);
ReplaceWithStubCall(node, callable, flags); ReplaceWithStubCall(node, callable, flags);
......
...@@ -1045,13 +1045,12 @@ const Operator* JSOperatorBuilder::CreateLiteralObject( ...@@ -1045,13 +1045,12 @@ const Operator* JSOperatorBuilder::CreateLiteralObject(
parameters); // parameter parameters); // parameter
} }
const Operator* JSOperatorBuilder::CreateEmptyLiteralObject(int literal_index) { const Operator* JSOperatorBuilder::CreateEmptyLiteralObject() {
return new (zone()) Operator1<int>( // -- return new (zone()) Operator( // --
IrOpcode::kJSCreateEmptyLiteralObject, // opcode IrOpcode::kJSCreateEmptyLiteralObject, // opcode
Operator::kNoProperties, // properties Operator::kNoProperties, // properties
"JSCreateEmptyLiteralObject", // name "JSCreateEmptyLiteralObject", // name
1, 1, 1, 1, 1, 2, // counts 1, 1, 1, 1, 1, 2); // counts
literal_index); // parameter
} }
const Operator* JSOperatorBuilder::CreateLiteralRegExp( const Operator* JSOperatorBuilder::CreateLiteralRegExp(
......
...@@ -637,7 +637,7 @@ class V8_EXPORT_PRIVATE JSOperatorBuilder final ...@@ -637,7 +637,7 @@ class V8_EXPORT_PRIVATE JSOperatorBuilder final
int literal_flags, int literal_index, int literal_flags, int literal_index,
int number_of_elements); int number_of_elements);
const Operator* CreateEmptyLiteralArray(int literal_index); const Operator* CreateEmptyLiteralArray(int literal_index);
const Operator* CreateEmptyLiteralObject(int literal_index); const Operator* CreateEmptyLiteralObject();
const Operator* CreateLiteralObject(Handle<BoilerplateDescription> constant, const Operator* CreateLiteralObject(Handle<BoilerplateDescription> constant,
int literal_flags, int literal_index, int literal_flags, int literal_index,
......
...@@ -977,9 +977,8 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CreateObjectLiteral( ...@@ -977,9 +977,8 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CreateObjectLiteral(
return *this; return *this;
} }
BytecodeArrayBuilder& BytecodeArrayBuilder::CreateEmptyObjectLiteral( BytecodeArrayBuilder& BytecodeArrayBuilder::CreateEmptyObjectLiteral() {
int literal_index) { OutputCreateEmptyObjectLiteral();
OutputCreateEmptyObjectLiteral(literal_index);
return *this; return *this;
} }
......
...@@ -225,7 +225,7 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final ...@@ -225,7 +225,7 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final
BytecodeArrayBuilder& CreateObjectLiteral(size_t constant_properties_entry, BytecodeArrayBuilder& CreateObjectLiteral(size_t constant_properties_entry,
int literal_index, int flags, int literal_index, int flags,
Register output); Register output);
BytecodeArrayBuilder& CreateEmptyObjectLiteral(int literal_index); BytecodeArrayBuilder& CreateEmptyObjectLiteral();
// Push the context in accumulator as the new context, and store in register // Push the context in accumulator as the new context, and store in register
// |context|. // |context|.
......
...@@ -1904,16 +1904,15 @@ void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { ...@@ -1904,16 +1904,15 @@ void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
} }
void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
int literal_index = feedback_index(expr->literal_slot());
// Fast path for the empty object literal which doesn't need an // Fast path for the empty object literal which doesn't need an
// AllocationSite. // AllocationSite.
if (expr->IsEmptyObjectLiteral()) { if (expr->IsEmptyObjectLiteral()) {
DCHECK(expr->IsFastCloningSupported()); DCHECK(expr->IsFastCloningSupported());
builder()->CreateEmptyObjectLiteral(literal_index); builder()->CreateEmptyObjectLiteral();
return; return;
} }
int literal_index = feedback_index(expr->literal_slot());
// Deep-copy the literal boilerplate. // Deep-copy the literal boilerplate.
uint8_t flags = CreateObjectLiteralFlags::Encode( uint8_t flags = CreateObjectLiteralFlags::Encode(
expr->ComputeFlags(), expr->IsFastCloningSupported()); expr->ComputeFlags(), expr->IsFastCloningSupported());
......
...@@ -230,7 +230,7 @@ namespace interpreter { ...@@ -230,7 +230,7 @@ namespace interpreter {
V(CreateEmptyArrayLiteral, AccumulatorUse::kWrite, OperandType::kIdx) \ V(CreateEmptyArrayLiteral, AccumulatorUse::kWrite, OperandType::kIdx) \
V(CreateObjectLiteral, AccumulatorUse::kNone, OperandType::kIdx, \ V(CreateObjectLiteral, AccumulatorUse::kNone, OperandType::kIdx, \
OperandType::kIdx, OperandType::kFlag8, OperandType::kRegOut) \ OperandType::kIdx, OperandType::kFlag8, OperandType::kRegOut) \
V(CreateEmptyObjectLiteral, AccumulatorUse::kWrite, OperandType::kIdx) \ V(CreateEmptyObjectLiteral, AccumulatorUse::kWrite) \
\ \
/* Closure allocation */ \ /* Closure allocation */ \
V(CreateClosure, AccumulatorUse::kWrite, OperandType::kIdx, \ V(CreateClosure, AccumulatorUse::kWrite, OperandType::kIdx, \
......
...@@ -2707,12 +2707,10 @@ IGNITION_HANDLER(CreateObjectLiteral, InterpreterAssembler) { ...@@ -2707,12 +2707,10 @@ IGNITION_HANDLER(CreateObjectLiteral, InterpreterAssembler) {
} }
} }
// CreateEmptyObjectLiteral <literal_idx> // CreateEmptyObjectLiteral
// //
// Creates an empty JSObject literal for literal index <literal_idx>. // Creates an empty JSObject literal.
IGNITION_HANDLER(CreateEmptyObjectLiteral, InterpreterAssembler) { IGNITION_HANDLER(CreateEmptyObjectLiteral, InterpreterAssembler) {
// TODO(cbruni): remove literal_index and closure parameter once we know
// whether empty object literals work without pretenuring support.
Node* context = GetContext(); Node* context = GetContext();
ConstructorBuiltinsAssembler constructor_assembler(state()); ConstructorBuiltinsAssembler constructor_assembler(state());
Node* result = constructor_assembler.EmitCreateEmptyObjectLiteral(context); Node* result = constructor_assembler.EmitCreateEmptyObjectLiteral(context);
......
...@@ -11,10 +11,10 @@ snippet: " ...@@ -11,10 +11,10 @@ snippet: "
" "
frame size: 0 frame size: 0
parameter count: 1 parameter count: 1
bytecode array length: 4 bytecode array length: 3
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
/* 34 S> */ B(CreateEmptyObjectLiteral), U8(0), /* 34 S> */ B(CreateEmptyObjectLiteral),
/* 45 S> */ B(Return), /* 45 S> */ B(Return),
] ]
constant pool: [ constant pool: [
...@@ -333,7 +333,7 @@ snippet: " ...@@ -333,7 +333,7 @@ snippet: "
" "
frame size: 4 frame size: 4
parameter count: 1 parameter count: 1
bytecode array length: 34 bytecode array length: 33
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaConstant), U8(0), /* 42 S> */ B(LdaConstant), U8(0),
...@@ -342,7 +342,7 @@ bytecodes: [ ...@@ -342,7 +342,7 @@ bytecodes: [
/* 60 E> */ B(ToName), R(2), /* 60 E> */ B(ToName), R(2),
B(LdaSmi), I8(1), B(LdaSmi), I8(1),
B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(2), B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(2),
B(CreateEmptyObjectLiteral), U8(0), B(CreateEmptyObjectLiteral),
B(Star), R(3), B(Star), R(3),
B(Mov), R(1), R(2), B(Mov), R(1), R(2),
B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(2), U8(2), B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(2), U8(2),
......
...@@ -353,7 +353,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { ...@@ -353,7 +353,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
.CreateArrayLiteral(0, 0, 0) .CreateArrayLiteral(0, 0, 0)
.CreateEmptyArrayLiteral(0) .CreateEmptyArrayLiteral(0)
.CreateObjectLiteral(0, 0, 0, reg) .CreateObjectLiteral(0, 0, 0, reg)
.CreateEmptyObjectLiteral(0); .CreateEmptyObjectLiteral();
// Emit load and store operations for module variables. // Emit load and store operations for module variables.
builder.LoadModuleVariable(-1, 42) builder.LoadModuleVariable(-1, 42)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment