Commit e8a0a371 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[interpreter] Merge StaGlobal[Sloppy/Strict] into one bytecode.

Given that we already treat feedback vector as a source of truth for
language mode of other store operations and given that the StoreGlobalIC
dispatcher does not depend on the language more anymore, we can just combine
these two bytecodes.

Bug: v8:7206
Change-Id: I27f03f2102ff79ec20fa997eb18dde816f376b00
Reviewed-on: https://chromium-review.googlesource.com/823846Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50102}
parent f57ba6b9
...@@ -950,7 +950,7 @@ void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() { ...@@ -950,7 +950,7 @@ void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() {
environment()->BindAccumulator(node, Environment::kAttachFrameState); environment()->BindAccumulator(node, Environment::kAttachFrameState);
} }
void BytecodeGraphBuilder::BuildStoreGlobal(LanguageMode language_mode) { void BytecodeGraphBuilder::VisitStaGlobal() {
PrepareEagerCheckpoint(); PrepareEagerCheckpoint();
Handle<Name> name = Handle<Name> name =
Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0));
...@@ -958,19 +958,13 @@ void BytecodeGraphBuilder::BuildStoreGlobal(LanguageMode language_mode) { ...@@ -958,19 +958,13 @@ void BytecodeGraphBuilder::BuildStoreGlobal(LanguageMode language_mode) {
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1));
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
LanguageMode language_mode =
feedback.vector()->GetLanguageMode(feedback.slot());
const Operator* op = javascript()->StoreGlobal(language_mode, name, feedback); const Operator* op = javascript()->StoreGlobal(language_mode, name, feedback);
Node* node = NewNode(op, value); Node* node = NewNode(op, value);
environment()->RecordAfterState(node, Environment::kAttachFrameState); environment()->RecordAfterState(node, Environment::kAttachFrameState);
} }
void BytecodeGraphBuilder::VisitStaGlobalSloppy() {
BuildStoreGlobal(LanguageMode::kSloppy);
}
void BytecodeGraphBuilder::VisitStaGlobalStrict() {
BuildStoreGlobal(LanguageMode::kStrict);
}
void BytecodeGraphBuilder::VisitStaDataPropertyInLiteral() { void BytecodeGraphBuilder::VisitStaDataPropertyInLiteral() {
PrepareEagerCheckpoint(); PrepareEagerCheckpoint();
......
...@@ -155,7 +155,6 @@ class BytecodeGraphBuilder { ...@@ -155,7 +155,6 @@ class BytecodeGraphBuilder {
void BuildCreateArguments(CreateArgumentsType type); void BuildCreateArguments(CreateArgumentsType type);
Node* BuildLoadGlobal(Handle<Name> name, uint32_t feedback_slot_index, Node* BuildLoadGlobal(Handle<Name> name, uint32_t feedback_slot_index,
TypeofMode typeof_mode); TypeofMode typeof_mode);
void BuildStoreGlobal(LanguageMode language_mode);
enum class StoreMode { enum class StoreMode {
// Check the prototype chain before storing. // Check the prototype chain before storing.
......
...@@ -701,14 +701,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal(const AstRawString* name, ...@@ -701,14 +701,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal(const AstRawString* name,
} }
BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal( BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal(
const AstRawString* name, int feedback_slot, LanguageMode language_mode) { const AstRawString* name, int feedback_slot) {
size_t name_index = GetConstantPoolEntry(name); size_t name_index = GetConstantPoolEntry(name);
if (language_mode == LanguageMode::kSloppy) { OutputStaGlobal(name_index, feedback_slot);
OutputStaGlobalSloppy(name_index, feedback_slot);
} else {
DCHECK_EQ(language_mode, LanguageMode::kStrict);
OutputStaGlobalStrict(name_index, feedback_slot);
}
return *this; return *this;
} }
......
...@@ -85,8 +85,8 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final { ...@@ -85,8 +85,8 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final {
// Global loads to the accumulator and stores from the accumulator. // Global loads to the accumulator and stores from the accumulator.
BytecodeArrayBuilder& LoadGlobal(const AstRawString* name, int feedback_slot, BytecodeArrayBuilder& LoadGlobal(const AstRawString* name, int feedback_slot,
TypeofMode typeof_mode); TypeofMode typeof_mode);
BytecodeArrayBuilder& StoreGlobal(const AstRawString* name, int feedback_slot, BytecodeArrayBuilder& StoreGlobal(const AstRawString* name,
LanguageMode language_mode); int feedback_slot);
// Load the object at |slot_index| at |depth| in the context chain starting // Load the object at |slot_index| at |depth| in the context chain starting
// with |context| into the accumulator. // with |context| into the accumulator.
......
...@@ -2557,8 +2557,7 @@ void BytecodeGenerator::BuildVariableAssignment( ...@@ -2557,8 +2557,7 @@ void BytecodeGenerator::BuildVariableAssignment(
// TODO(ishell): consider using FeedbackSlotCache for variables here. // TODO(ishell): consider using FeedbackSlotCache for variables here.
FeedbackSlot slot = FeedbackSlot slot =
feedback_spec()->AddStoreGlobalICSlot(language_mode()); feedback_spec()->AddStoreGlobalICSlot(language_mode());
builder()->StoreGlobal(variable->raw_name(), feedback_index(slot), builder()->StoreGlobal(variable->raw_name(), feedback_index(slot));
language_mode());
break; break;
} }
case VariableLocation::CONTEXT: { case VariableLocation::CONTEXT: {
......
...@@ -42,10 +42,7 @@ namespace interpreter { ...@@ -42,10 +42,7 @@ namespace interpreter {
V(LdaGlobal, AccumulatorUse::kWrite, OperandType::kIdx, OperandType::kIdx) \ V(LdaGlobal, AccumulatorUse::kWrite, OperandType::kIdx, OperandType::kIdx) \
V(LdaGlobalInsideTypeof, AccumulatorUse::kWrite, OperandType::kIdx, \ V(LdaGlobalInsideTypeof, AccumulatorUse::kWrite, OperandType::kIdx, \
OperandType::kIdx) \ OperandType::kIdx) \
V(StaGlobalSloppy, AccumulatorUse::kRead, OperandType::kIdx, \ V(StaGlobal, AccumulatorUse::kRead, OperandType::kIdx, OperandType::kIdx) \
OperandType::kIdx) \
V(StaGlobalStrict, AccumulatorUse::kRead, OperandType::kIdx, \
OperandType::kIdx) \
\ \
/* Context operations */ \ /* Context operations */ \
V(PushContext, AccumulatorUse::kRead, OperandType::kRegOut) \ V(PushContext, AccumulatorUse::kRead, OperandType::kRegOut) \
......
...@@ -245,46 +245,23 @@ IGNITION_HANDLER(LdaGlobalInsideTypeof, InterpreterLoadGlobalAssembler) { ...@@ -245,46 +245,23 @@ IGNITION_HANDLER(LdaGlobalInsideTypeof, InterpreterLoadGlobalAssembler) {
LdaGlobal(kSlotOperandIndex, kNameOperandIndex, INSIDE_TYPEOF); LdaGlobal(kSlotOperandIndex, kNameOperandIndex, INSIDE_TYPEOF);
} }
class InterpreterStoreGlobalAssembler : public InterpreterAssembler { // StaGlobal <name_index> <slot>
public: //
InterpreterStoreGlobalAssembler(CodeAssemblerState* state, Bytecode bytecode, // Store the value in the accumulator into the global with name in constant pool
OperandScale operand_scale) // entry <name_index> using FeedBackVector slot <slot>.
: InterpreterAssembler(state, bytecode, operand_scale) {} IGNITION_HANDLER(StaGlobal, InterpreterAssembler) {
void StaGlobal(Callable ic) {
// Get the global object.
Node* context = GetContext(); Node* context = GetContext();
// Store the global via the StoreIC. // Store the global via the StoreGlobalIC.
Node* code_target = HeapConstant(ic.code());
Node* constant_index = BytecodeOperandIdx(0); Node* constant_index = BytecodeOperandIdx(0);
Node* name = LoadConstantPoolEntry(constant_index); Node* name = LoadConstantPoolEntry(constant_index);
Node* value = GetAccumulator(); Node* value = GetAccumulator();
Node* raw_slot = BytecodeOperandIdx(1); Node* raw_slot = BytecodeOperandIdx(1);
Node* smi_slot = SmiTag(raw_slot); Node* smi_slot = SmiTag(raw_slot);
Node* feedback_vector = LoadFeedbackVector(); Node* feedback_vector = LoadFeedbackVector();
CallStub(ic.descriptor(), code_target, context, name, value, smi_slot,
feedback_vector);
Dispatch();
}
};
// StaGlobalSloppy <name_index> <slot>
//
// Store the value in the accumulator into the global with name in constant pool
// entry <name_index> using FeedBackVector slot <slot> in sloppy mode.
IGNITION_HANDLER(StaGlobalSloppy, InterpreterStoreGlobalAssembler) {
Callable ic = Builtins::CallableFor(isolate(), Builtins::kStoreGlobalIC);
StaGlobal(ic);
}
// StaGlobalStrict <name_index> <slot>
//
// Store the value in the accumulator into the global with name in constant pool
// entry <name_index> using FeedBackVector slot <slot> in strict mode.
IGNITION_HANDLER(StaGlobalStrict, InterpreterStoreGlobalAssembler) {
Callable ic = Builtins::CallableFor(isolate(), Builtins::kStoreGlobalIC); Callable ic = Builtins::CallableFor(isolate(), Builtins::kStoreGlobalIC);
StaGlobal(ic); CallStub(ic, context, name, value, smi_slot, feedback_vector);
Dispatch();
} }
// LdaContextSlot <context> <slot_index> <depth> // LdaContextSlot <context> <slot_index> <depth>
......
...@@ -22,7 +22,7 @@ bytecodes: [ ...@@ -22,7 +22,7 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kDeclareGlobalsForInterpreter), R(1), U8(3), B(CallRuntime), U16(Runtime::kDeclareGlobalsForInterpreter), R(1), U8(3),
/* 0 E> */ B(StackCheck), /* 0 E> */ B(StackCheck),
/* 8 S> */ B(LdaSmi), I8(1), /* 8 S> */ B(LdaSmi), I8(1),
/* 8 E> */ B(StaGlobalSloppy), U8(1), U8(2), /* 8 E> */ B(StaGlobal), U8(1), U8(2),
B(LdaUndefined), B(LdaUndefined),
/* 10 S> */ B(Return), /* 10 S> */ B(Return),
] ]
...@@ -74,9 +74,9 @@ bytecodes: [ ...@@ -74,9 +74,9 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kDeclareGlobalsForInterpreter), R(1), U8(3), B(CallRuntime), U16(Runtime::kDeclareGlobalsForInterpreter), R(1), U8(3),
/* 0 E> */ B(StackCheck), /* 0 E> */ B(StackCheck),
/* 8 S> */ B(LdaSmi), I8(1), /* 8 S> */ B(LdaSmi), I8(1),
/* 8 E> */ B(StaGlobalSloppy), U8(1), U8(2), /* 8 E> */ B(StaGlobal), U8(1), U8(2),
/* 11 S> */ B(LdaSmi), I8(2), /* 11 S> */ B(LdaSmi), I8(2),
/* 12 E> */ B(StaGlobalSloppy), U8(1), U8(4), /* 12 E> */ B(StaGlobal), U8(1), U8(4),
B(Star), R(0), B(Star), R(0),
/* 15 S> */ B(Return), /* 15 S> */ B(Return),
] ]
......
...@@ -19,7 +19,7 @@ bytecodes: [ ...@@ -19,7 +19,7 @@ bytecodes: [
/* 26 E> */ B(StackCheck), /* 26 E> */ B(StackCheck),
/* 31 S> */ B(LdaGlobal), U8(0), U8(0), /* 31 S> */ B(LdaGlobal), U8(0), U8(0),
B(BitwiseAndSmi), I8(1), U8(2), B(BitwiseAndSmi), I8(1), U8(2),
/* 45 E> */ B(StaGlobalSloppy), U8(0), U8(3), /* 45 E> */ B(StaGlobal), U8(0), U8(3),
/* 50 S> */ B(Return), /* 50 S> */ B(Return),
] ]
constant pool: [ constant pool: [
...@@ -41,7 +41,7 @@ bytecodes: [ ...@@ -41,7 +41,7 @@ bytecodes: [
/* 27 E> */ B(StackCheck), /* 27 E> */ B(StackCheck),
/* 32 S> */ B(LdaGlobal), U8(0), U8(0), /* 32 S> */ B(LdaGlobal), U8(0), U8(0),
B(AddSmi), I8(1), U8(2), B(AddSmi), I8(1), U8(2),
/* 51 E> */ B(StaGlobalSloppy), U8(0), U8(3), /* 51 E> */ B(StaGlobal), U8(0), U8(3),
/* 56 S> */ B(Return), /* 56 S> */ B(Return),
] ]
constant pool: [ constant pool: [
......
...@@ -19,7 +19,7 @@ bytecodes: [ ...@@ -19,7 +19,7 @@ bytecodes: [
/* 26 E> */ B(StackCheck), /* 26 E> */ B(StackCheck),
/* 31 S> */ B(LdaGlobal), U8(0), U8(0), /* 31 S> */ B(LdaGlobal), U8(0), U8(0),
B(Inc), U8(2), B(Inc), U8(2),
/* 40 E> */ B(StaGlobalSloppy), U8(0), U8(3), /* 40 E> */ B(StaGlobal), U8(0), U8(3),
/* 47 S> */ B(Return), /* 47 S> */ B(Return),
] ]
constant pool: [ constant pool: [
...@@ -43,7 +43,7 @@ bytecodes: [ ...@@ -43,7 +43,7 @@ bytecodes: [
B(ToNumeric), U8(2), B(ToNumeric), U8(2),
B(Star), R(0), B(Star), R(0),
B(Dec), U8(2), B(Dec), U8(2),
/* 44 E> */ B(StaGlobalSloppy), U8(0), U8(3), /* 44 E> */ B(StaGlobal), U8(0), U8(3),
B(Ldar), R(0), B(Ldar), R(0),
/* 47 S> */ B(Return), /* 47 S> */ B(Return),
] ]
...@@ -66,7 +66,7 @@ bytecodes: [ ...@@ -66,7 +66,7 @@ bytecodes: [
/* 27 E> */ B(StackCheck), /* 27 E> */ B(StackCheck),
/* 46 S> */ B(LdaGlobal), U8(0), U8(0), /* 46 S> */ B(LdaGlobal), U8(0), U8(0),
B(Dec), U8(2), B(Dec), U8(2),
/* 55 E> */ B(StaGlobalStrict), U8(0), U8(3), /* 55 E> */ B(StaGlobal), U8(0), U8(3),
/* 67 S> */ B(Return), /* 67 S> */ B(Return),
] ]
constant pool: [ constant pool: [
...@@ -90,7 +90,7 @@ bytecodes: [ ...@@ -90,7 +90,7 @@ bytecodes: [
B(ToNumeric), U8(2), B(ToNumeric), U8(2),
B(Star), R(0), B(Star), R(0),
B(Inc), U8(2), B(Inc), U8(2),
/* 50 E> */ B(StaGlobalSloppy), U8(0), U8(3), /* 50 E> */ B(StaGlobal), U8(0), U8(3),
B(Ldar), R(0), B(Ldar), R(0),
/* 53 S> */ B(Return), /* 53 S> */ B(Return),
] ]
......
...@@ -18,7 +18,7 @@ bytecode array length: 8 ...@@ -18,7 +18,7 @@ bytecode array length: 8
bytecodes: [ bytecodes: [
/* 21 E> */ B(StackCheck), /* 21 E> */ B(StackCheck),
/* 26 S> */ B(LdaSmi), I8(2), /* 26 S> */ B(LdaSmi), I8(2),
/* 28 E> */ B(StaGlobalSloppy), U8(0), U8(0), /* 28 E> */ B(StaGlobal), U8(0), U8(0),
B(LdaUndefined), B(LdaUndefined),
/* 33 S> */ B(Return), /* 33 S> */ B(Return),
] ]
...@@ -39,7 +39,7 @@ bytecode array length: 8 ...@@ -39,7 +39,7 @@ bytecode array length: 8
bytecodes: [ bytecodes: [
/* 26 E> */ B(StackCheck), /* 26 E> */ B(StackCheck),
/* 32 S> */ B(Ldar), R(arg0), /* 32 S> */ B(Ldar), R(arg0),
/* 34 E> */ B(StaGlobalSloppy), U8(0), U8(0), /* 34 E> */ B(StaGlobal), U8(0), U8(0),
B(LdaUndefined), B(LdaUndefined),
/* 39 S> */ B(Return), /* 39 S> */ B(Return),
] ]
...@@ -61,7 +61,7 @@ bytecode array length: 8 ...@@ -61,7 +61,7 @@ bytecode array length: 8
bytecodes: [ bytecodes: [
/* 35 E> */ B(StackCheck), /* 35 E> */ B(StackCheck),
/* 40 S> */ B(LdaSmi), I8(2), /* 40 S> */ B(LdaSmi), I8(2),
/* 42 E> */ B(StaGlobalStrict), U8(0), U8(0), /* 42 E> */ B(StaGlobal), U8(0), U8(0),
B(LdaUndefined), B(LdaUndefined),
/* 47 S> */ B(Return), /* 47 S> */ B(Return),
] ]
...@@ -83,7 +83,7 @@ bytecode array length: 8 ...@@ -83,7 +83,7 @@ bytecode array length: 8
bytecodes: [ bytecodes: [
/* 17 E> */ B(StackCheck), /* 17 E> */ B(StackCheck),
/* 22 S> */ B(LdaSmi), I8(2), /* 22 S> */ B(LdaSmi), I8(2),
/* 24 E> */ B(StaGlobalSloppy), U8(0), U8(0), /* 24 E> */ B(StaGlobal), U8(0), U8(0),
B(LdaUndefined), B(LdaUndefined),
/* 29 S> */ B(Return), /* 29 S> */ B(Return),
] ]
...@@ -363,7 +363,7 @@ bytecodes: [ ...@@ -363,7 +363,7 @@ bytecodes: [
/* 1287 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(252), /* 1287 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(252),
/* 1297 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(254), /* 1297 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(254),
/* 1305 S> */ B(LdaSmi), I8(2), /* 1305 S> */ B(LdaSmi), I8(2),
/* 1307 E> */ B(Wide), B(StaGlobalSloppy), U16(1), U16(256), /* 1307 E> */ B(Wide), B(StaGlobal), U16(1), U16(256),
B(LdaUndefined), B(LdaUndefined),
/* 1312 S> */ B(Return), /* 1312 S> */ B(Return),
] ]
...@@ -645,7 +645,7 @@ bytecodes: [ ...@@ -645,7 +645,7 @@ bytecodes: [
/* 1303 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(252), /* 1303 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(252),
/* 1313 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(254), /* 1313 S> */ B(LdaNamedProperty), R(arg0), U8(0), U8(254),
/* 1321 S> */ B(LdaSmi), I8(2), /* 1321 S> */ B(LdaSmi), I8(2),
/* 1323 E> */ B(Wide), B(StaGlobalStrict), U16(1), U16(256), /* 1323 E> */ B(Wide), B(StaGlobal), U16(1), U16(256),
B(LdaUndefined), B(LdaUndefined),
/* 1328 S> */ B(Return), /* 1328 S> */ B(Return),
] ]
......
...@@ -25,7 +25,7 @@ bytecodes: [ ...@@ -25,7 +25,7 @@ bytecodes: [
B(CreateClosure), U8(2), U8(3), U8(0), B(CreateClosure), U8(2), U8(3), U8(0),
B(StaNamedOwnProperty), R(1), U8(3), U8(4), B(StaNamedOwnProperty), R(1), U8(3), U8(4),
B(Ldar), R(1), B(Ldar), R(1),
/* 8 E> */ B(StaGlobalSloppy), U8(4), U8(6), /* 8 E> */ B(StaGlobal), U8(4), U8(6),
B(LdaUndefined), B(LdaUndefined),
/* 33 S> */ B(Return), /* 33 S> */ B(Return),
] ]
......
...@@ -93,8 +93,6 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { ...@@ -93,8 +93,6 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
feedback_spec.AddLoadGlobalICSlot(INSIDE_TYPEOF); feedback_spec.AddLoadGlobalICSlot(INSIDE_TYPEOF);
FeedbackSlot sloppy_store_global_slot = FeedbackSlot sloppy_store_global_slot =
feedback_spec.AddStoreGlobalICSlot(LanguageMode::kSloppy); feedback_spec.AddStoreGlobalICSlot(LanguageMode::kSloppy);
FeedbackSlot strict_store_global_slot =
feedback_spec.AddStoreGlobalICSlot(LanguageMode::kStrict);
FeedbackSlot load_slot = feedback_spec.AddLoadICSlot(); FeedbackSlot load_slot = feedback_spec.AddLoadICSlot();
FeedbackSlot keyed_load_slot = feedback_spec.AddKeyedLoadICSlot(); FeedbackSlot keyed_load_slot = feedback_spec.AddKeyedLoadICSlot();
FeedbackSlot sloppy_store_slot = FeedbackSlot sloppy_store_slot =
...@@ -113,10 +111,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { ...@@ -113,10 +111,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
.LoadGlobal(name, load_global_slot.ToInt(), TypeofMode::NOT_INSIDE_TYPEOF) .LoadGlobal(name, load_global_slot.ToInt(), TypeofMode::NOT_INSIDE_TYPEOF)
.LoadGlobal(name, load_global_typeof_slot.ToInt(), .LoadGlobal(name, load_global_typeof_slot.ToInt(),
TypeofMode::INSIDE_TYPEOF) TypeofMode::INSIDE_TYPEOF)
.StoreGlobal(name, sloppy_store_global_slot.ToInt(), .StoreGlobal(name, sloppy_store_global_slot.ToInt());
LanguageMode::kSloppy)
.StoreGlobal(name, strict_store_global_slot.ToInt(),
LanguageMode::kStrict);
// Emit context operations. // Emit context operations.
builder.PushContext(reg) builder.PushContext(reg)
......
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