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