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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 RECURSE(Visit(stmt->init())); | 240 RECURSE(Visit(stmt->init())); |
241 } | 241 } |
242 store_.Forget(); // Control may transfer here via looping. | 242 store_.Forget(); // Control may transfer here via looping. |
243 if (stmt->cond() != NULL) { | 243 if (stmt->cond() != NULL) { |
244 // Collect type feedback. | 244 // Collect type feedback. |
245 stmt->cond()->RecordToBooleanTypeFeedback(oracle()); | 245 stmt->cond()->RecordToBooleanTypeFeedback(oracle()); |
246 | 246 |
247 RECURSE(Visit(stmt->cond())); | 247 RECURSE(Visit(stmt->cond())); |
248 } | 248 } |
249 RECURSE(Visit(stmt->body())); | 249 RECURSE(Visit(stmt->body())); |
250 store_.Forget(); // Control may transfer here via 'continue'. | |
251 if (stmt->next() != NULL) { | 250 if (stmt->next() != NULL) { |
| 251 store_.Forget(); // Control may transfer here via 'continue'. |
252 RECURSE(Visit(stmt->next())); | 252 RECURSE(Visit(stmt->next())); |
253 } | 253 } |
254 store_.Forget(); // Control may transfer here via termination or 'break'. | 254 store_.Forget(); // Control may transfer here via termination or 'break'. |
255 } | 255 } |
256 | 256 |
257 | 257 |
258 void AstTyper::VisitForInStatement(ForInStatement* stmt) { | 258 void AstTyper::VisitForInStatement(ForInStatement* stmt) { |
259 // Collect type feedback. | 259 // Collect type feedback. |
260 stmt->RecordTypeFeedback(oracle()); | 260 stmt->RecordTypeFeedback(oracle()); |
261 | 261 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 expr->left()->bounds(), expr->right()->bounds(), isolate_)); | 573 expr->left()->bounds(), expr->right()->bounds(), isolate_)); |
574 break; | 574 break; |
575 } | 575 } |
576 case Token::BIT_OR: | 576 case Token::BIT_OR: |
577 case Token::BIT_AND: { | 577 case Token::BIT_AND: { |
578 RECURSE(Visit(expr->left())); | 578 RECURSE(Visit(expr->left())); |
579 RECURSE(Visit(expr->right())); | 579 RECURSE(Visit(expr->right())); |
580 Type* upper = Type::Union( | 580 Type* upper = Type::Union( |
581 expr->left()->bounds().upper, expr->right()->bounds().upper); | 581 expr->left()->bounds().upper, expr->right()->bounds().upper); |
582 if (!upper->Is(Type::Signed32())) upper = Type::Signed32(); | 582 if (!upper->Is(Type::Signed32())) upper = Type::Signed32(); |
583 NarrowType(expr, Bounds(Type::Smi(), upper, isolate_)); | 583 Type* lower = Type::Intersect( |
| 584 handle(Type::Smi(), isolate_), handle(upper, isolate_)); |
| 585 NarrowType(expr, Bounds(lower, upper, isolate_)); |
584 break; | 586 break; |
585 } | 587 } |
586 case Token::BIT_XOR: | 588 case Token::BIT_XOR: |
587 case Token::SHL: | 589 case Token::SHL: |
588 case Token::SAR: | 590 case Token::SAR: |
589 RECURSE(Visit(expr->left())); | 591 RECURSE(Visit(expr->left())); |
590 RECURSE(Visit(expr->right())); | 592 RECURSE(Visit(expr->right())); |
591 NarrowType(expr, Bounds(Type::Smi(), Type::Signed32(), isolate_)); | 593 NarrowType(expr, Bounds(Type::Smi(), Type::Signed32(), isolate_)); |
592 break; | 594 break; |
593 case Token::SHR: | 595 case Token::SHR: |
594 RECURSE(Visit(expr->left())); | 596 RECURSE(Visit(expr->left())); |
595 RECURSE(Visit(expr->right())); | 597 RECURSE(Visit(expr->right())); |
596 NarrowType(expr, Bounds(Type::Smi(), Type::Unsigned32(), isolate_)); | 598 // TODO(rossberg): we could use an UnsignedSmi as lower bound here... |
| 599 NarrowType(expr, Bounds(Type::Unsigned32(), isolate_)); |
597 break; | 600 break; |
598 case Token::ADD: { | 601 case Token::ADD: { |
599 RECURSE(Visit(expr->left())); | 602 RECURSE(Visit(expr->left())); |
600 RECURSE(Visit(expr->right())); | 603 RECURSE(Visit(expr->right())); |
601 Bounds l = expr->left()->bounds(); | 604 Bounds l = expr->left()->bounds(); |
602 Bounds r = expr->right()->bounds(); | 605 Bounds r = expr->right()->bounds(); |
603 Type* lower = | 606 Type* lower = |
| 607 l.lower->Is(Type::None()) || r.lower->Is(Type::None()) ? |
| 608 Type::None() : |
| 609 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ? |
| 610 Type::String() : |
604 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ? | 611 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ? |
605 Type::Smi() : | 612 Type::Smi() : Type::None(); |
606 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ? | |
607 Type::String() : Type::None(); | |
608 Type* upper = | 613 Type* upper = |
| 614 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ? |
| 615 Type::String() : |
609 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ? | 616 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ? |
610 Type::Number() : | 617 Type::Number() : Type::NumberOrString(); |
611 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ? | |
612 Type::String() : Type::NumberOrString(); | |
613 NarrowType(expr, Bounds(lower, upper, isolate_)); | 618 NarrowType(expr, Bounds(lower, upper, isolate_)); |
614 break; | 619 break; |
615 } | 620 } |
616 case Token::SUB: | 621 case Token::SUB: |
617 case Token::MUL: | 622 case Token::MUL: |
618 case Token::DIV: | 623 case Token::DIV: |
619 case Token::MOD: | 624 case Token::MOD: |
620 RECURSE(Visit(expr->left())); | 625 RECURSE(Visit(expr->left())); |
621 RECURSE(Visit(expr->right())); | 626 RECURSE(Visit(expr->right())); |
622 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); | 627 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 void AstTyper::VisitModuleUrl(ModuleUrl* module) { | 700 void AstTyper::VisitModuleUrl(ModuleUrl* module) { |
696 } | 701 } |
697 | 702 |
698 | 703 |
699 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { | 704 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { |
700 RECURSE(Visit(stmt->body())); | 705 RECURSE(Visit(stmt->body())); |
701 } | 706 } |
702 | 707 |
703 | 708 |
704 } } // namespace v8::internal | 709 } } // namespace v8::internal |
OLD | NEW |