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

Side by Side Diff: src/rewriter.cc

Issue 844006: Merge changes up to V8 version 2.1.3 into the partial snapshots (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/register-allocator-inl.h ('k') | src/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 if (var->type()->IsKnown()) { 237 if (var->type()->IsKnown()) {
238 node->type()->CopyFrom(var->type()); 238 node->type()->CopyFrom(var->type());
239 } else if (node->type()->IsLikelySmi()) { 239 } else if (node->type()->IsLikelySmi()) {
240 var->type()->SetAsLikelySmi(); 240 var->type()->SetAsLikelySmi();
241 } 241 }
242 242
243 if (!var->is_this() && 243 if (!var->is_this() &&
244 !Heap::result_symbol()->Equals(*var->name())) { 244 !Heap::result_symbol()->Equals(*var->name())) {
245 func_name_inferrer_.PushName(var->name()); 245 func_name_inferrer_.PushName(var->name());
246 } 246 }
247
248 if (FLAG_safe_int32_compiler) {
249 if (var->IsStackAllocated() && !var->is_arguments()) {
250 node->set_side_effect_free(true);
251 }
252 }
247 } 253 }
248 } 254 }
249 255
250 256
251 void AstOptimizer::VisitLiteral(Literal* node) { 257 void AstOptimizer::VisitLiteral(Literal* node) {
252 Handle<Object> literal = node->handle(); 258 Handle<Object> literal = node->handle();
253 if (literal->IsSmi()) { 259 if (literal->IsSmi()) {
254 node->type()->SetAsLikelySmi(); 260 node->type()->SetAsLikelySmi();
261 node->set_side_effect_free(true);
255 } else if (literal->IsString()) { 262 } else if (literal->IsString()) {
256 Handle<String> lit_str(Handle<String>::cast(literal)); 263 Handle<String> lit_str(Handle<String>::cast(literal));
257 if (!Heap::prototype_symbol()->Equals(*lit_str)) { 264 if (!Heap::prototype_symbol()->Equals(*lit_str)) {
258 func_name_inferrer_.PushName(lit_str); 265 func_name_inferrer_.PushName(lit_str);
259 } 266 }
267 } else if (literal->IsHeapNumber()) {
268 node->set_side_effect_free(true);
260 } 269 }
261 } 270 }
262 271
263 272
264 void AstOptimizer::VisitRegExpLiteral(RegExpLiteral* node) { 273 void AstOptimizer::VisitRegExpLiteral(RegExpLiteral* node) {
265 USE(node); 274 USE(node);
266 } 275 }
267 276
268 277
269 void AstOptimizer::VisitArrayLiteral(ArrayLiteral* node) { 278 void AstOptimizer::VisitArrayLiteral(ArrayLiteral* node) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 node->arguments()->length() >= 2 && 416 node->arguments()->length() >= 2 &&
408 node->arguments()->at(1)->AsFunctionLiteral() != NULL) { 417 node->arguments()->at(1)->AsFunctionLiteral() != NULL) {
409 scoped_fni.Enter(); 418 scoped_fni.Enter();
410 } 419 }
411 OptimizeArguments(node->arguments()); 420 OptimizeArguments(node->arguments());
412 } 421 }
413 422
414 423
415 void AstOptimizer::VisitUnaryOperation(UnaryOperation* node) { 424 void AstOptimizer::VisitUnaryOperation(UnaryOperation* node) {
416 Visit(node->expression()); 425 Visit(node->expression());
426 if (FLAG_safe_int32_compiler) {
427 switch (node->op()) {
428 case Token::BIT_NOT:
429 node->expression()->set_to_int32(true);
430 // Fall through.
431 case Token::ADD:
432 case Token::SUB:
433 case Token::NOT:
434 node->set_side_effect_free(node->expression()->side_effect_free());
435 break;
436 case Token::DELETE:
437 case Token::TYPEOF:
438 case Token::VOID:
439 break;
440 default:
441 UNREACHABLE();
442 break;
443 }
444 } else if (node->op() == Token::BIT_NOT) {
445 node->expression()->set_to_int32(true);
446 }
417 } 447 }
418 448
419 449
420 void AstOptimizer::VisitCountOperation(CountOperation* node) { 450 void AstOptimizer::VisitCountOperation(CountOperation* node) {
421 // Count operations assume that they work on Smis. 451 // Count operations assume that they work on Smis.
422 node->type()->SetAsLikelySmiIfUnknown(); 452 node->type()->SetAsLikelySmiIfUnknown();
423 node->expression()->type()->SetAsLikelySmiIfUnknown(); 453 node->expression()->type()->SetAsLikelySmiIfUnknown();
424 Visit(node->expression()); 454 Visit(node->expression());
425 } 455 }
426 456
427 457
428 void AstOptimizer::VisitBinaryOperation(BinaryOperation* node) { 458 void AstOptimizer::VisitBinaryOperation(BinaryOperation* node) {
429 // Depending on the operation we can propagate this node's type down the 459 // Depending on the operation we can propagate this node's type down the
430 // AST nodes. 460 // AST nodes.
431 switch (node->op()) { 461 switch (node->op()) {
432 case Token::COMMA: 462 case Token::COMMA:
433 case Token::OR: 463 case Token::OR:
434 case Token::AND: 464 case Token::AND:
435 break; 465 break;
436 case Token::BIT_OR: 466 case Token::BIT_OR:
437 case Token::BIT_XOR: 467 case Token::BIT_XOR:
438 case Token::BIT_AND: 468 case Token::BIT_AND:
439 case Token::SHL: 469 case Token::SHL:
440 case Token::SAR: 470 case Token::SAR:
441 case Token::SHR: 471 case Token::SHR:
442 node->type()->SetAsLikelySmiIfUnknown(); 472 node->type()->SetAsLikelySmiIfUnknown();
443 node->left()->type()->SetAsLikelySmiIfUnknown(); 473 node->left()->type()->SetAsLikelySmiIfUnknown();
444 node->right()->type()->SetAsLikelySmiIfUnknown(); 474 node->right()->type()->SetAsLikelySmiIfUnknown();
475 node->left()->set_to_int32(true);
476 node->right()->set_to_int32(true);
445 break; 477 break;
446 case Token::ADD: 478 case Token::ADD:
447 case Token::SUB: 479 case Token::SUB:
448 case Token::MUL: 480 case Token::MUL:
449 case Token::DIV: 481 case Token::DIV:
450 case Token::MOD: 482 case Token::MOD:
451 if (node->type()->IsLikelySmi()) { 483 if (node->type()->IsLikelySmi()) {
452 node->left()->type()->SetAsLikelySmiIfUnknown(); 484 node->left()->type()->SetAsLikelySmiIfUnknown();
453 node->right()->type()->SetAsLikelySmiIfUnknown(); 485 node->right()->type()->SetAsLikelySmiIfUnknown();
454 } 486 }
(...skipping 21 matching lines...) Expand all
476 if (node->left()->type()->IsUnknown()) { 508 if (node->left()->type()->IsUnknown()) {
477 node->left()->type()->SetAsLikelySmi(); 509 node->left()->type()->SetAsLikelySmi();
478 Visit(node->left()); 510 Visit(node->left());
479 } 511 }
480 if (node->right()->type()->IsUnknown()) { 512 if (node->right()->type()->IsUnknown()) {
481 node->right()->type()->SetAsLikelySmi(); 513 node->right()->type()->SetAsLikelySmi();
482 Visit(node->right()); 514 Visit(node->right());
483 } 515 }
484 } 516 }
485 } 517 }
518
519 if (FLAG_safe_int32_compiler) {
520 switch (node->op()) {
521 case Token::COMMA:
522 case Token::OR:
523 case Token::AND:
524 break;
525 case Token::BIT_OR:
526 case Token::BIT_XOR:
527 case Token::BIT_AND:
528 case Token::SHL:
529 case Token::SAR:
530 case Token::SHR:
531 case Token::ADD:
532 case Token::SUB:
533 case Token::MUL:
534 case Token::DIV:
535 case Token::MOD:
536 node->set_side_effect_free(node->left()->side_effect_free() &&
537 node->right()->side_effect_free());
538 break;
539 default:
540 UNREACHABLE();
541 break;
542 }
543 }
486 } 544 }
487 545
488 546
489 void AstOptimizer::VisitCompareOperation(CompareOperation* node) { 547 void AstOptimizer::VisitCompareOperation(CompareOperation* node) {
490 if (node->type()->IsKnown()) { 548 if (node->type()->IsKnown()) {
491 // Propagate useful information down towards the leafs. 549 // Propagate useful information down towards the leafs.
492 node->left()->type()->SetAsLikelySmiIfUnknown(); 550 node->left()->type()->SetAsLikelySmiIfUnknown();
493 node->right()->type()->SetAsLikelySmiIfUnknown(); 551 node->right()->type()->SetAsLikelySmiIfUnknown();
494 } 552 }
495 553
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 optimizer.Optimize(body); 904 optimizer.Optimize(body);
847 if (optimizer.HasStackOverflow()) { 905 if (optimizer.HasStackOverflow()) {
848 return false; 906 return false;
849 } 907 }
850 } 908 }
851 return true; 909 return true;
852 } 910 }
853 911
854 912
855 } } // namespace v8::internal 913 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/register-allocator-inl.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698