Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 926013002: TF: Add support for [[HomeObject]] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 50216a766c074ec10c30872e6cf9f842288101ac..50e202939aa4cce386678a5e287d6d3a9ded9488 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -1357,15 +1357,7 @@ void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
}
}
- // TODO(mstarzinger): This is temporary to make "super" work and replicates
- // the existing FullCodeGenerator::NeedsHomeObject predicate.
- if (FunctionLiteral::NeedsHomeObject(property->value())) {
- Unique<Name> name =
- MakeUnique(isolate()->factory()->home_object_symbol());
- Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
- value, receiver);
- PrepareFrameState(store, BailoutId::None());
- }
+ AddHomeObjectIfNeeded(property->value(), value, receiver);
}
// Transform both the class literal and the prototype to fast properties.
@@ -1385,6 +1377,17 @@ 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();
}
@@ -1486,6 +1489,8 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
NewNode(javascript()->StoreNamed(language_mode(), name),
literal, value);
PrepareFrameState(store, key->id());
+
+ AddHomeObjectIfNeeded(property->value(), value, literal);
} else {
VisitForEffect(property->value());
}
@@ -1502,6 +1507,8 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
const Operator* op =
javascript()->CallRuntime(Runtime::kSetProperty, 4);
NewNode(op, receiver, key, value, language);
+
+ AddHomeObjectIfNeeded(property->value(), value, receiver);
}
break;
}
@@ -1541,6 +1548,8 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
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);
@@ -1573,6 +1582,8 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
Node* key = environment()->Pop();
Node* receiver = environment()->Pop();
+ AddHomeObjectIfNeeded(property->value(), value, receiver);
+
switch (property->kind()) {
case ObjectLiteral::Property::CONSTANT:
case ObjectLiteral::Property::COMPUTED:

Powered by Google App Engine
This is Rietveld 408576698