Commit b82a49e6 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Cleanup AstGraphBuilder::AddHomeObjectIfNeeded a bit.

R=rossberg@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#26677}
parent 066d1633
......@@ -1335,6 +1335,8 @@ void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
Node* value = environment()->Pop();
Node* key = environment()->Pop();
Node* receiver = environment()->Pop();
BuildSetHomeObject(value, receiver, property->value());
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
case ObjectLiteral::Property::MATERIALIZED_LITERAL:
......@@ -1361,8 +1363,6 @@ void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
break;
}
}
AddHomeObjectIfNeeded(property->value(), value, receiver);
}
// Transform both the class literal and the prototype to fast properties.
......@@ -1382,17 +1382,6 @@ void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
}
void AstGraphBuilder::AddHomeObjectIfNeeded(Expression* expr, Node* function,
Node* home_object) {
if (FunctionLiteral::NeedsHomeObject(expr)) {
Unique<Name> name = MakeUnique(isolate()->factory()->home_object_symbol());
Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
function, home_object);
PrepareFrameState(store, BailoutId::None());
}
}
void AstGraphBuilder::VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) {
UNREACHABLE();
}
......@@ -1494,8 +1483,7 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
NewNode(javascript()->StoreNamed(language_mode(), name),
literal, value);
PrepareFrameState(store, key->id());
AddHomeObjectIfNeeded(property->value(), value, literal);
BuildSetHomeObject(value, literal, property->value());
} else {
VisitForEffect(property->value());
}
......@@ -1512,8 +1500,7 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
const Operator* op =
javascript()->CallRuntime(Runtime::kSetProperty, 4);
NewNode(op, receiver, key, value, language);
AddHomeObjectIfNeeded(property->value(), value, receiver);
BuildSetHomeObject(value, receiver, property->value());
}
break;
}
......@@ -1549,12 +1536,12 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
it != accessor_table.end(); ++it) {
VisitForValue(it->first);
VisitForValueOrNull(it->second->getter);
BuildSetHomeObject(environment()->Top(), literal, it->second->getter);
VisitForValueOrNull(it->second->setter);
BuildSetHomeObject(environment()->Top(), literal, it->second->setter);
Node* setter = environment()->Pop();
Node* getter = environment()->Pop();
Node* name = environment()->Pop();
AddHomeObjectIfNeeded(it->second->getter, getter, literal);
AddHomeObjectIfNeeded(it->second->setter, setter, literal);
Node* attr = jsgraph()->Constant(NONE);
const Operator* op =
javascript()->CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
......@@ -1586,8 +1573,7 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
Node* value = environment()->Pop();
Node* key = environment()->Pop();
Node* receiver = environment()->Pop();
AddHomeObjectIfNeeded(property->value(), value, receiver);
BuildSetHomeObject(value, receiver, property->value());
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
......@@ -2804,6 +2790,17 @@ Node* AstGraphBuilder::BuildToName(Node* input, BailoutId bailout_id) {
}
Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object,
Expression* expr) {
if (!FunctionLiteral::NeedsHomeObject(expr)) return value;
Unique<Name> name = MakeUnique(isolate()->factory()->home_object_symbol());
const Operator* op = javascript()->StoreNamed(language_mode(), name);
Node* store = NewNode(op, value, home_object);
PrepareFrameState(store, BailoutId::None());
return store;
}
Node* AstGraphBuilder::BuildThrowReferenceError(Variable* variable,
BailoutId bailout_id) {
// TODO(mstarzinger): Should be unified with the VisitThrow implementation.
......
......@@ -226,10 +226,9 @@ class AstGraphBuilder : public AstVisitor {
Node* BuildToBoolean(Node* value);
Node* BuildToName(Node* value, BailoutId bailout_id);
// Adds the [[HomeObject]] to a value if the value came from a function
// literal that needs a home object.
void AddHomeObjectIfNeeded(Expression* expr, Node* function,
Node* home_object);
// Builder for adding the [[HomeObject]] to a value if the value came from a
// function literal and needs a home object. Do nothing otherwise.
Node* BuildSetHomeObject(Node* value, Node* home_object, Expression* expr);
// Builders for error reporting at runtime.
Node* BuildThrowReferenceError(Variable* var, BailoutId bailout_id);
......
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