| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 RECURSE(Visit(stmt->init())); | 245 RECURSE(Visit(stmt->init())); |
| 246 } | 246 } |
| 247 store_.Forget(); // Control may transfer here via looping. | 247 store_.Forget(); // Control may transfer here via looping. |
| 248 if (stmt->cond() != NULL) { | 248 if (stmt->cond() != NULL) { |
| 249 // Collect type feedback. | 249 // Collect type feedback. |
| 250 stmt->cond()->RecordToBooleanTypeFeedback(oracle()); | 250 stmt->cond()->RecordToBooleanTypeFeedback(oracle()); |
| 251 | 251 |
| 252 RECURSE(Visit(stmt->cond())); | 252 RECURSE(Visit(stmt->cond())); |
| 253 } | 253 } |
| 254 RECURSE(Visit(stmt->body())); | 254 RECURSE(Visit(stmt->body())); |
| 255 store_.Forget(); // Control may transfer here via 'continue'. | |
| 256 if (stmt->next() != NULL) { | 255 if (stmt->next() != NULL) { |
| 256 store_.Forget(); // Control may transfer here via 'continue'. |
| 257 RECURSE(Visit(stmt->next())); | 257 RECURSE(Visit(stmt->next())); |
| 258 } | 258 } |
| 259 store_.Forget(); // Control may transfer here via termination or 'break'. | 259 store_.Forget(); // Control may transfer here via termination or 'break'. |
| 260 } | 260 } |
| 261 | 261 |
| 262 | 262 |
| 263 void AstTyper::VisitForInStatement(ForInStatement* stmt) { | 263 void AstTyper::VisitForInStatement(ForInStatement* stmt) { |
| 264 // Collect type feedback. | 264 // Collect type feedback. |
| 265 stmt->RecordTypeFeedback(oracle()); | 265 stmt->RecordTypeFeedback(oracle()); |
| 266 | 266 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 store_.Seq(left_effects); | 575 store_.Seq(left_effects); |
| 576 | 576 |
| 577 NarrowType(expr, Bounds::Either( | 577 NarrowType(expr, Bounds::Either( |
| 578 expr->left()->bounds(), expr->right()->bounds(), isolate_)); | 578 expr->left()->bounds(), expr->right()->bounds(), isolate_)); |
| 579 break; | 579 break; |
| 580 } | 580 } |
| 581 case Token::BIT_OR: | 581 case Token::BIT_OR: |
| 582 case Token::BIT_AND: { | 582 case Token::BIT_AND: { |
| 583 RECURSE(Visit(expr->left())); | 583 RECURSE(Visit(expr->left())); |
| 584 RECURSE(Visit(expr->right())); | 584 RECURSE(Visit(expr->right())); |
| 585 Type* upper = Type::Union( | 585 Handle<Type> upper( |
| 586 expr->left()->bounds().upper, expr->right()->bounds().upper); | 586 Type::Union( |
| 587 if (!upper->Is(Type::Signed32())) upper = Type::Signed32(); | 587 expr->left()->bounds().upper, expr->right()->bounds().upper), |
| 588 NarrowType(expr, Bounds(Type::Smi(), upper, isolate_)); | 588 isolate_); |
| 589 if (!upper->Is(Type::Signed32())) upper = |
| 590 handle(Type::Signed32(), isolate_); |
| 591 Handle<Type> lower(Type::Intersect( |
| 592 handle(Type::Smi(), isolate_), upper), isolate_); |
| 593 NarrowType(expr, Bounds(lower, upper)); |
| 589 break; | 594 break; |
| 590 } | 595 } |
| 591 case Token::BIT_XOR: | 596 case Token::BIT_XOR: |
| 592 case Token::SHL: | 597 case Token::SHL: |
| 593 case Token::SAR: | 598 case Token::SAR: |
| 594 RECURSE(Visit(expr->left())); | 599 RECURSE(Visit(expr->left())); |
| 595 RECURSE(Visit(expr->right())); | 600 RECURSE(Visit(expr->right())); |
| 596 NarrowType(expr, Bounds(Type::Smi(), Type::Signed32(), isolate_)); | 601 NarrowType(expr, Bounds(Type::Smi(), Type::Signed32(), isolate_)); |
| 597 break; | 602 break; |
| 598 case Token::SHR: | 603 case Token::SHR: |
| 599 RECURSE(Visit(expr->left())); | 604 RECURSE(Visit(expr->left())); |
| 600 RECURSE(Visit(expr->right())); | 605 RECURSE(Visit(expr->right())); |
| 601 NarrowType(expr, Bounds(Type::Smi(), Type::Unsigned32(), isolate_)); | 606 // TODO(rossberg): we could use an UnsignedSmi as lower bound here... |
| 607 NarrowType(expr, Bounds(Type::Unsigned32(), isolate_)); |
| 602 break; | 608 break; |
| 603 case Token::ADD: { | 609 case Token::ADD: { |
| 604 RECURSE(Visit(expr->left())); | 610 RECURSE(Visit(expr->left())); |
| 605 RECURSE(Visit(expr->right())); | 611 RECURSE(Visit(expr->right())); |
| 606 Bounds l = expr->left()->bounds(); | 612 Bounds l = expr->left()->bounds(); |
| 607 Bounds r = expr->right()->bounds(); | 613 Bounds r = expr->right()->bounds(); |
| 608 Type* lower = | 614 Type* lower = |
| 615 l.lower->Is(Type::None()) || r.lower->Is(Type::None()) ? |
| 616 Type::None() : |
| 617 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ? |
| 618 Type::String() : |
| 609 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ? | 619 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ? |
| 610 Type::Smi() : | 620 Type::Smi() : Type::None(); |
| 611 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ? | |
| 612 Type::String() : Type::None(); | |
| 613 Type* upper = | 621 Type* upper = |
| 622 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ? |
| 623 Type::String() : |
| 614 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ? | 624 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ? |
| 615 Type::Number() : | 625 Type::Number() : Type::NumberOrString(); |
| 616 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ? | |
| 617 Type::String() : Type::NumberOrString(); | |
| 618 NarrowType(expr, Bounds(lower, upper, isolate_)); | 626 NarrowType(expr, Bounds(lower, upper, isolate_)); |
| 619 break; | 627 break; |
| 620 } | 628 } |
| 621 case Token::SUB: | 629 case Token::SUB: |
| 622 case Token::MUL: | 630 case Token::MUL: |
| 623 case Token::DIV: | 631 case Token::DIV: |
| 624 case Token::MOD: | 632 case Token::MOD: |
| 625 RECURSE(Visit(expr->left())); | 633 RECURSE(Visit(expr->left())); |
| 626 RECURSE(Visit(expr->right())); | 634 RECURSE(Visit(expr->right())); |
| 627 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); | 635 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 void AstTyper::VisitModuleUrl(ModuleUrl* module) { | 708 void AstTyper::VisitModuleUrl(ModuleUrl* module) { |
| 701 } | 709 } |
| 702 | 710 |
| 703 | 711 |
| 704 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { | 712 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { |
| 705 RECURSE(Visit(stmt->body())); | 713 RECURSE(Visit(stmt->body())); |
| 706 } | 714 } |
| 707 | 715 |
| 708 | 716 |
| 709 } } // namespace v8::internal | 717 } } // namespace v8::internal |
| OLD | NEW |