Commit 5fdf5c1e authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[interpreter] Remove special "prototype" load in class literals.

This allows us to remove the somewhat awkward BuildLoadObjectField
from the BytecodeGraphBuilder and also allows us to simplify the
bytecode stream for class literals.

R=oth@chromium.org

Review URL: https://codereview.chromium.org/1678103002

Cr-Commit-Position: refs/heads/master@{#33820}
parent 90721a51
......@@ -488,12 +488,6 @@ Node* BytecodeGraphBuilder::GetFunctionClosure() {
}
Node* BytecodeGraphBuilder::BuildLoadObjectField(Node* object, int offset) {
return NewNode(jsgraph()->machine()->Load(MachineType::AnyTagged()), object,
jsgraph()->IntPtrConstant(offset - kHeapObjectTag));
}
Node* BytecodeGraphBuilder::BuildLoadImmutableObjectField(Node* object,
int offset) {
return graph()->NewNode(jsgraph()->machine()->Load(MachineType::AnyTagged()),
......@@ -963,13 +957,6 @@ void BytecodeGraphBuilder::VisitKeyedStoreICStrictWide() {
BuildKeyedStore();
}
void BytecodeGraphBuilder::VisitLdaInitialMap() {
Node* js_function = environment()->LookupAccumulator();
Node* load = BuildLoadObjectField(js_function,
JSFunction::kPrototypeOrInitialMapOffset);
environment()->BindAccumulator(load);
}
void BytecodeGraphBuilder::VisitPushContext() {
Node* new_context = environment()->LookupAccumulator();
environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0),
......
......@@ -41,7 +41,6 @@ class BytecodeGraphBuilder {
Node* GetNewTarget();
// Builder for accessing a (potentially immutable) object field.
Node* BuildLoadObjectField(Node* object, int offset);
Node* BuildLoadImmutableObjectField(Node* object, int offset);
// Builder for accessing type feedback vector.
......
......@@ -332,11 +332,6 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::LoadBooleanConstant(bool value) {
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::LoadPrototypeOrInitialMap() {
Output(Bytecode::kLdaInitialMap);
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::LoadAccumulatorWithRegister(
Register reg) {
if (!IsRegisterInAccumulator(reg)) {
......
......@@ -91,9 +91,6 @@ class BytecodeArrayBuilder final : public ZoneObject, private RegisterMover {
BytecodeArrayBuilder& LoadFalse();
BytecodeArrayBuilder& LoadBooleanConstant(bool value);
// Load object prototype (or initial map).
BytecodeArrayBuilder& LoadPrototypeOrInitialMap();
// Global loads to the accumulator and stores from the accumulator.
BytecodeArrayBuilder& LoadGlobal(const Handle<String> name, int feedback_slot,
LanguageMode language_mode,
......
......@@ -1244,15 +1244,16 @@ void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) {
void BytecodeGenerator::VisitClassLiteralContents(ClassLiteral* expr) {
VisitClassLiteralForRuntimeDefinition(expr);
// The prototype is ensured to exist by Runtime_DefineClass in
// VisitClassForRuntimeDefinition. No access check is needed here
// since the constructor is created by the class literal.
// Load the "prototype" from the constructor.
register_allocator()->PrepareForConsecutiveAllocations(2);
Register literal = register_allocator()->NextConsecutiveRegister();
Register prototype = register_allocator()->NextConsecutiveRegister();
Handle<String> name = isolate()->factory()->prototype_string();
FeedbackVectorSlot slot = expr->PrototypeSlot();
builder()
->StoreAccumulatorInRegister(literal)
.LoadPrototypeOrInitialMap()
.LoadNamedProperty(literal, name, feedback_index(slot), language_mode())
.StoreAccumulatorInRegister(prototype);
VisitClassLiteralProperties(expr, literal, prototype);
......
......@@ -142,9 +142,6 @@ namespace interpreter {
V(KeyedStoreICStrictWide, OperandType::kReg8, OperandType::kReg8, \
OperandType::kIdx16) \
\
/* Class information */ \
V(LdaInitialMap, OperandType::kNone) \
\
/* Binary Operators */ \
V(Add, OperandType::kReg8) \
V(Sub, OperandType::kReg8) \
......
......@@ -829,18 +829,6 @@ void Interpreter::DoKeyedStoreICStrictWide(
DoKeyedStoreIC(ic, assembler);
}
// LdaInitialMap
//
// Loads the prototype or initial map of the JSFunction referenced by
// the accumulator. The result is placed in the accumulator.
void Interpreter::DoLdaInitialMap(compiler::InterpreterAssembler* assembler) {
Node* js_function = __ GetAccumulator();
Node* initial_map =
__ LoadObjectField(js_function, JSFunction::kPrototypeOrInitialMapOffset);
__ SetAccumulator(initial_map);
__ Dispatch();
}
// PushContext <context>
//
// Saves the current context in <context>, and pushes the accumulator as the
......
......@@ -9042,7 +9042,7 @@ DISABLED_TEST(ClassDeclarations) {
B(Star), R(5), //
B(CallRuntime), U16(Runtime::kDefineClass), R(2), U8(4), //
B(Star), R(2), //
B(LdaInitialMap), //
B(LoadICSloppy), //
B(Star), R(3), //
B(Mov), R(3), R(4), //
B(LdaConstant), U8(2), //
......@@ -9083,7 +9083,7 @@ DISABLED_TEST(ClassDeclarations) {
B(Star), R(5), //
B(CallRuntime), U16(Runtime::kDefineClass), R(2), U8(4), //
B(Star), R(2), //
B(LdaInitialMap), //
B(LoadICSloppy), //
B(Star), R(3), //
B(Mov), R(3), R(4), //
B(LdaConstant), U8(2), //
......@@ -9133,7 +9133,7 @@ DISABLED_TEST(ClassDeclarations) {
B(Star), R(6), //
B(CallRuntime), U16(Runtime::kDefineClass), R(3), U8(4), //
B(Star), R(3), //
B(LdaInitialMap), //
B(LoadICSloppy), //
B(Star), R(4), //
B(Mov), R(4), R(5), //
B(LdaContextSlot), R(context), U8(4), //
......@@ -9193,7 +9193,7 @@ DISABLED_TEST(ClassDeclarations) {
B(Star), R(6), //
B(CallRuntime), U16(Runtime::kDefineClass), R(3), U8(4), //
B(Star), R(3), //
B(LdaInitialMap), //
B(LoadICSloppy), //
B(Star), R(4), //
B(CallRuntime), U16(Runtime::kFinalizeClassDefinition), R(3), U8(2), //
B(Star), R(0), //
......
......@@ -54,9 +54,6 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
builder.MoveRegister(reg, other);
builder.MoveRegister(reg, wide);
// Prototype info for classes.
builder.LoadPrototypeOrInitialMap();
// Emit global load / store operations.
Factory* factory = isolate()->factory();
Handle<String> name = factory->NewStringFromStaticChars("var_name");
......
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