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

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

Issue 925363003: Cleanup AstGraphBuilder::AddHomeObjectIfNeeded a bit. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_trycatch-3
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
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 49a3abd7d3d8e3e5e177c87ac63e4e2851d368ff..8c5fa4594009bc268d25a9f4b11cd289bcdd0b60 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -1345,6 +1345,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:
@@ -1371,8 +1373,6 @@ void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
break;
}
}
-
- AddHomeObjectIfNeeded(property->value(), value, receiver);
}
// Transform both the class literal and the prototype to fast properties.
@@ -1392,17 +1392,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();
}
@@ -1504,8 +1493,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());
}
@@ -1522,8 +1510,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;
}
@@ -1559,12 +1546,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);
@@ -1596,8 +1583,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:
@@ -2814,6 +2800,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;
arv (Not doing code reviews) 2015/02/16 20:09:56 What is the return value used for here?
Michael Starzinger 2015/02/16 20:30:35 It's not used, but for symmetry all builder method
+}
+
+
Node* AstGraphBuilder::BuildThrowReferenceError(Variable* variable,
BailoutId bailout_id) {
// TODO(mstarzinger): Should be unified with the VisitThrow implementation.
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698