Commit d273636e authored by arv's avatar arv Committed by Commit bot

TF: Add support for [[HomeObject]]

BUG=None
LOG=N
R=mstarzinger@chromium.org, dslomov@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#26641}
parent cc362227
......@@ -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:
......
......@@ -227,6 +227,11 @@ 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);
// Builders for error reporting at runtime.
Node* BuildThrowReferenceError(Variable* var, BailoutId bailout_id);
Node* BuildThrowConstAssignError(BailoutId bailout_id);
......
......@@ -115,11 +115,6 @@
'regress/regress-354433': [PASS, NO_VARIANTS], # only on ARM simulator.
'regress/regress-crbug-259300': [PASS, NO_VARIANTS],
# TODO(arv): TurboFan does not yet add [[HomeObject]] as needed.
'harmony/object-literals-super': [PASS, NO_VARIANTS],
'harmony/super': [PASS, NO_VARIANTS],
'harmony/computed-property-names-super': [PASS, NO_VARIANTS],
##############################################################################
# Too slow in debug mode with --stress-opt mode.
'compiler/regress-stacktrace-methods': [PASS, ['mode == debug', SKIP]],
......
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