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

Unified Diff: src/fast-codegen.cc

Issue 598016: Restrict the syntax that we aggressively optimize. (Closed)
Patch Set: Created 10 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 | « no previous file | test/mjsunit/compiler/simple-bailouts.js » ('j') | test/mjsunit/compiler/simple-bailouts.js » ('J')
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 587cda8061e3878f012f02ec3e9fc2afa6e326ec..19091dafa81bbd89f9951145d20388b238042b45 100644
--- a/src/fast-codegen.cc
+++ b/src/fast-codegen.cc
@@ -89,10 +89,10 @@ void FastCodeGenSyntaxChecker::VisitDeclarations(
void FastCodeGenSyntaxChecker::VisitStatements(ZoneList<Statement*>* stmts) {
- for (int i = 0, len = stmts->length(); i < len; i++) {
- Visit(stmts->at(i));
- CHECK_BAILOUT;
+ if (stmts->length() != 1) {
+ BAILOUT("Function body is not a singleton statement.");
}
+ Visit(stmts->at(0));
}
@@ -276,6 +276,9 @@ void FastCodeGenSyntaxChecker::VisitAssignment(Assignment* expr) {
Handle<String> name = Handle<String>::cast(key->handle());
LookupResult lookup;
receiver->Lookup(*name, &lookup);
+ if (!lookup.IsValid()) {
+ BAILOUT("Assigned property not found at compile time");
+ }
if (lookup.holder() != *receiver) BAILOUT("Non-own property assignment");
if (!lookup.type() == FIELD) BAILOUT("Non-field property assignment");
} else {
@@ -311,6 +314,9 @@ void FastCodeGenSyntaxChecker::VisitProperty(Property* expr) {
Handle<String> name = Handle<String>::cast(key->handle());
LookupResult lookup;
receiver->Lookup(*name, &lookup);
+ if (!lookup.IsValid()) {
+ BAILOUT("Referenced property not found at compile time");
+ }
if (lookup.holder() != *receiver) BAILOUT("Non-own property reference");
if (!lookup.type() == FIELD) BAILOUT("Non-field property reference");
} else {
@@ -360,6 +366,16 @@ void FastCodeGenSyntaxChecker::VisitBinaryOperation(BinaryOperation* expr) {
// a pair of registers to keep all intermediate values in registers
// (i.e., the expression stack has height no more than two).
if (!expr->right()->IsLeaf()) BAILOUT("expression nested on right");
+
+ // We do not allow subexpressions with side effects because we
+ // (currently) bail out to the beginning of the full function. The
+ // only expressions with side effects that we would otherwise handle
+ // are assignments.
+ if (expr->left()->AsAssignment() != NULL ||
+ expr->right()->AsAssignment() != NULL) {
+ BAILOUT("subexpression of binary operation has side effects");
+ }
+
Visit(expr->left());
CHECK_BAILOUT;
Visit(expr->right());
« no previous file with comments | « no previous file | test/mjsunit/compiler/simple-bailouts.js » ('j') | test/mjsunit/compiler/simple-bailouts.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698