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

Unified Diff: src/fast-codegen.cc

Issue 551189: Propagate receiver from initial call site to code generator. (Closed)
Patch Set: Created 10 years, 11 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
« src/compiler.h ('K') | « src/fast-codegen.h ('k') | src/handles.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/fast-codegen.cc
diff --git a/src/fast-codegen.cc b/src/fast-codegen.cc
index 4e2df74f9e1ee42763da0a3e4d8530a528fa6b6d..adca9908064d52eee0981cec09cf6281aa221d7b 100644
--- a/src/fast-codegen.cc
+++ b/src/fast-codegen.cc
@@ -50,10 +50,12 @@ namespace internal {
void FastCodeGenSyntaxChecker::Check(FunctionLiteral* fun) {
- Scope* scope = fun->scope();
+ // We do not specialize if we do not have a receiver.
+ if (receiver().is_null()) BAILOUT("No receiver");
// We do not support stack or heap slots (both of which require
// allocation).
+ Scope* scope = fun->scope();
if (scope->num_stack_slots() > 0) {
BAILOUT("Function has stack-allocated locals");
}
@@ -246,6 +248,21 @@ void FastCodeGenSyntaxChecker::VisitAssignment(Assignment* expr) {
BAILOUT("Non-named-property assignment");
}
+ // We will only specialize for fields on the object itself.
+ // Expression::IsPropertyName implies that the name is a literal
+ // symbol but we do not assume that.
+ Literal* key = prop->key()->AsLiteral();
+ if (key != NULL && key->handle()->IsString()) {
+ Handle<String> name = Handle<String>::cast(key->handle());
+ LookupResult lookup;
+ receiver()->Lookup(*name, &lookup);
+ if (lookup.holder() != *receiver()) BAILOUT("Non-own property assignment");
+ if (!lookup.type() == FIELD) BAILOUT("Non-field property assignment");
+ } else {
+ UNREACHABLE();
+ BAILOUT("Unexpected non-string-literal property key");
+ }
+
Visit(expr->value());
}
« src/compiler.h ('K') | « src/fast-codegen.h ('k') | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698