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'. |
250 if (stmt->next() != NULL) { | 251 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 Type* lower = Type::Intersect( | 583 NarrowType(expr, Bounds(Type::Smi(), upper, isolate_)); |
584 handle(Type::Smi(), isolate_), handle(upper, isolate_)); | |
585 NarrowType(expr, Bounds(lower, upper, isolate_)); | |
586 break; | 584 break; |
587 } | 585 } |
588 case Token::BIT_XOR: | 586 case Token::BIT_XOR: |
589 case Token::SHL: | 587 case Token::SHL: |
590 case Token::SAR: | 588 case Token::SAR: |
591 RECURSE(Visit(expr->left())); | 589 RECURSE(Visit(expr->left())); |
592 RECURSE(Visit(expr->right())); | 590 RECURSE(Visit(expr->right())); |
593 NarrowType(expr, Bounds(Type::Smi(), Type::Signed32(), isolate_)); | 591 NarrowType(expr, Bounds(Type::Smi(), Type::Signed32(), isolate_)); |
594 break; | 592 break; |
595 case Token::SHR: | 593 case Token::SHR: |
596 RECURSE(Visit(expr->left())); | 594 RECURSE(Visit(expr->left())); |
597 RECURSE(Visit(expr->right())); | 595 RECURSE(Visit(expr->right())); |
598 // TODO(rossberg): we could use an UnsignedSmi as lower bound here... | 596 NarrowType(expr, Bounds(Type::Smi(), Type::Unsigned32(), isolate_)); |
599 NarrowType(expr, Bounds(Type::Unsigned32(), isolate_)); | |
600 break; | 597 break; |
601 case Token::ADD: { | 598 case Token::ADD: { |
602 RECURSE(Visit(expr->left())); | 599 RECURSE(Visit(expr->left())); |
603 RECURSE(Visit(expr->right())); | 600 RECURSE(Visit(expr->right())); |
604 Bounds l = expr->left()->bounds(); | 601 Bounds l = expr->left()->bounds(); |
605 Bounds r = expr->right()->bounds(); | 602 Bounds r = expr->right()->bounds(); |
606 Type* lower = | 603 Type* lower = |
607 l.lower->Is(Type::None()) || r.lower->Is(Type::None()) ? | 604 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ? |
608 Type::None() : | 605 Type::Smi() : |
609 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ? | 606 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ? |
610 Type::String() : | 607 Type::String() : Type::None(); |
611 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ? | |
612 Type::Smi() : Type::None(); | |
613 Type* upper = | 608 Type* upper = |
| 609 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ? |
| 610 Type::Number() : |
614 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ? | 611 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ? |
615 Type::String() : | 612 Type::String() : Type::NumberOrString(); |
616 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ? | |
617 Type::Number() : Type::NumberOrString(); | |
618 NarrowType(expr, Bounds(lower, upper, isolate_)); | 613 NarrowType(expr, Bounds(lower, upper, isolate_)); |
619 break; | 614 break; |
620 } | 615 } |
621 case Token::SUB: | 616 case Token::SUB: |
622 case Token::MUL: | 617 case Token::MUL: |
623 case Token::DIV: | 618 case Token::DIV: |
624 case Token::MOD: | 619 case Token::MOD: |
625 RECURSE(Visit(expr->left())); | 620 RECURSE(Visit(expr->left())); |
626 RECURSE(Visit(expr->right())); | 621 RECURSE(Visit(expr->right())); |
627 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); | 622 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) { | 695 void AstTyper::VisitModuleUrl(ModuleUrl* module) { |
701 } | 696 } |
702 | 697 |
703 | 698 |
704 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { | 699 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { |
705 RECURSE(Visit(stmt->body())); | 700 RECURSE(Visit(stmt->body())); |
706 } | 701 } |
707 | 702 |
708 | 703 |
709 } } // namespace v8::internal | 704 } } // namespace v8::internal |
OLD | NEW |