[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}
This commit is contained in:
mstarzinger 2016-02-08 07:19:59 -08:00 committed by Commit bot
parent 90721a51a3
commit 5fdf5c1e4d
9 changed files with 9 additions and 48 deletions

View File

@ -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),

View File

@ -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.

View File

@ -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)) {

View File

@ -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,

View File

@ -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);

View File

@ -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) \

View File

@ -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

View File

@ -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), //

View File

@ -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");