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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 84
85 void FastCodeGenSyntaxChecker::VisitDeclarations( 85 void FastCodeGenSyntaxChecker::VisitDeclarations(
86 ZoneList<Declaration*>* decls) { 86 ZoneList<Declaration*>* decls) {
87 if (!decls->is_empty()) BAILOUT("Function has declarations"); 87 if (!decls->is_empty()) BAILOUT("Function has declarations");
88 } 88 }
89 89
90 90
91 void FastCodeGenSyntaxChecker::VisitStatements(ZoneList<Statement*>* stmts) { 91 void FastCodeGenSyntaxChecker::VisitStatements(ZoneList<Statement*>* stmts) {
92 for (int i = 0, len = stmts->length(); i < len; i++) { 92 if (stmts->length() != 1) {
93 Visit(stmts->at(i)); 93 BAILOUT("Function body is not a singleton statement.");
94 CHECK_BAILOUT;
95 } 94 }
95 Visit(stmts->at(0));
96 } 96 }
97 97
98 98
99 void FastCodeGenSyntaxChecker::VisitDeclaration(Declaration* decl) { 99 void FastCodeGenSyntaxChecker::VisitDeclaration(Declaration* decl) {
100 UNREACHABLE(); 100 UNREACHABLE();
101 } 101 }
102 102
103 103
104 void FastCodeGenSyntaxChecker::VisitBlock(Block* stmt) { 104 void FastCodeGenSyntaxChecker::VisitBlock(Block* stmt) {
105 VisitStatements(stmt->statements()); 105 VisitStatements(stmt->statements());
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 // We will only specialize for fields on the object itself. 270 // We will only specialize for fields on the object itself.
271 // Expression::IsPropertyName implies that the name is a literal 271 // Expression::IsPropertyName implies that the name is a literal
272 // symbol but we do not assume that. 272 // symbol but we do not assume that.
273 Literal* key = prop->key()->AsLiteral(); 273 Literal* key = prop->key()->AsLiteral();
274 if (key != NULL && key->handle()->IsString()) { 274 if (key != NULL && key->handle()->IsString()) {
275 Handle<Object> receiver = info()->receiver(); 275 Handle<Object> receiver = info()->receiver();
276 Handle<String> name = Handle<String>::cast(key->handle()); 276 Handle<String> name = Handle<String>::cast(key->handle());
277 LookupResult lookup; 277 LookupResult lookup;
278 receiver->Lookup(*name, &lookup); 278 receiver->Lookup(*name, &lookup);
279 if (!lookup.IsValid()) {
280 BAILOUT("Assigned property not found at compile time");
281 }
279 if (lookup.holder() != *receiver) BAILOUT("Non-own property assignment"); 282 if (lookup.holder() != *receiver) BAILOUT("Non-own property assignment");
280 if (!lookup.type() == FIELD) BAILOUT("Non-field property assignment"); 283 if (!lookup.type() == FIELD) BAILOUT("Non-field property assignment");
281 } else { 284 } else {
282 UNREACHABLE(); 285 UNREACHABLE();
283 BAILOUT("Unexpected non-string-literal property key"); 286 BAILOUT("Unexpected non-string-literal property key");
284 } 287 }
285 288
286 Visit(expr->value()); 289 Visit(expr->value());
287 } 290 }
288 291
(...skipping 15 matching lines...) Expand all
304 307
305 // We will only specialize for fields on the object itself. 308 // We will only specialize for fields on the object itself.
306 // Expression::IsPropertyName implies that the name is a literal 309 // Expression::IsPropertyName implies that the name is a literal
307 // symbol but we do not assume that. 310 // symbol but we do not assume that.
308 Literal* key = expr->key()->AsLiteral(); 311 Literal* key = expr->key()->AsLiteral();
309 if (key != NULL && key->handle()->IsString()) { 312 if (key != NULL && key->handle()->IsString()) {
310 Handle<Object> receiver = info()->receiver(); 313 Handle<Object> receiver = info()->receiver();
311 Handle<String> name = Handle<String>::cast(key->handle()); 314 Handle<String> name = Handle<String>::cast(key->handle());
312 LookupResult lookup; 315 LookupResult lookup;
313 receiver->Lookup(*name, &lookup); 316 receiver->Lookup(*name, &lookup);
317 if (!lookup.IsValid()) {
318 BAILOUT("Referenced property not found at compile time");
319 }
314 if (lookup.holder() != *receiver) BAILOUT("Non-own property reference"); 320 if (lookup.holder() != *receiver) BAILOUT("Non-own property reference");
315 if (!lookup.type() == FIELD) BAILOUT("Non-field property reference"); 321 if (!lookup.type() == FIELD) BAILOUT("Non-field property reference");
316 } else { 322 } else {
317 UNREACHABLE(); 323 UNREACHABLE();
318 BAILOUT("Unexpected non-string-literal property key"); 324 BAILOUT("Unexpected non-string-literal property key");
319 } 325 }
320 } 326 }
321 327
322 328
323 void FastCodeGenSyntaxChecker::VisitCall(Call* expr) { 329 void FastCodeGenSyntaxChecker::VisitCall(Call* expr) {
(...skipping 29 matching lines...) Expand all
353 case Token::OR: 359 case Token::OR:
354 BAILOUT("BinaryOperation OR"); 360 BAILOUT("BinaryOperation OR");
355 case Token::AND: 361 case Token::AND:
356 BAILOUT("BinaryOperation AND"); 362 BAILOUT("BinaryOperation AND");
357 363
358 case Token::BIT_OR: 364 case Token::BIT_OR:
359 // We support expressions nested on the left because they only require 365 // We support expressions nested on the left because they only require
360 // a pair of registers to keep all intermediate values in registers 366 // a pair of registers to keep all intermediate values in registers
361 // (i.e., the expression stack has height no more than two). 367 // (i.e., the expression stack has height no more than two).
362 if (!expr->right()->IsLeaf()) BAILOUT("expression nested on right"); 368 if (!expr->right()->IsLeaf()) BAILOUT("expression nested on right");
369
370 // We do not allow subexpressions with side effects because we
371 // (currently) bail out to the beginning of the full function. The
372 // only expressions with side effects that we would otherwise handle
373 // are assignments.
374 if (expr->left()->AsAssignment() != NULL ||
375 expr->right()->AsAssignment() != NULL) {
376 BAILOUT("subexpression of binary operation has side effects");
377 }
378
363 Visit(expr->left()); 379 Visit(expr->left());
364 CHECK_BAILOUT; 380 CHECK_BAILOUT;
365 Visit(expr->right()); 381 Visit(expr->right());
366 break; 382 break;
367 383
368 case Token::BIT_XOR: 384 case Token::BIT_XOR:
369 BAILOUT("BinaryOperation BIT_XOR"); 385 BAILOUT("BinaryOperation BIT_XOR");
370 case Token::BIT_AND: 386 case Token::BIT_AND:
371 BAILOUT("BinaryOperation BIT_AND"); 387 BAILOUT("BinaryOperation BIT_AND");
372 case Token::SHL: 388 case Token::SHL:
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 724
709 725
710 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { 726 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
711 UNREACHABLE(); 727 UNREACHABLE();
712 } 728 }
713 729
714 #undef __ 730 #undef __
715 731
716 732
717 } } // namespace v8::internal 733 } } // namespace v8::internal
OLDNEW
« 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