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