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

Side by Side Diff: src/typing.cc

Issue 176843006: Introduce representation types (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use smi MSB Created 6 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
OLDNEW
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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 void AstTyper::VisitCountOperation(CountOperation* expr) { 605 void AstTyper::VisitCountOperation(CountOperation* expr) {
606 // Collect type feedback. 606 // Collect type feedback.
607 TypeFeedbackId store_id = expr->CountStoreFeedbackId(); 607 TypeFeedbackId store_id = expr->CountStoreFeedbackId();
608 expr->set_store_mode(oracle()->GetStoreMode(store_id)); 608 expr->set_store_mode(oracle()->GetStoreMode(store_id));
609 oracle()->CountReceiverTypes(store_id, expr->GetReceiverTypes()); 609 oracle()->CountReceiverTypes(store_id, expr->GetReceiverTypes());
610 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId())); 610 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId()));
611 // TODO(rossberg): merge the count type with the generic expression type. 611 // TODO(rossberg): merge the count type with the generic expression type.
612 612
613 RECURSE(Visit(expr->expression())); 613 RECURSE(Visit(expr->expression()));
614 614
615 NarrowType(expr, Bounds(Type::Smi(zone()), Type::Number(zone()))); 615 NarrowType(expr, Bounds(Type::SignedSmall(zone()), Type::Number(zone())));
616 616
617 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 617 VariableProxy* proxy = expr->expression()->AsVariableProxy();
618 if (proxy != NULL && proxy->var()->IsStackAllocated()) { 618 if (proxy != NULL && proxy->var()->IsStackAllocated()) {
619 store_.Seq(variable_index(proxy->var()), Effect(expr->bounds())); 619 store_.Seq(variable_index(proxy->var()), Effect(expr->bounds()));
620 } 620 }
621 } 621 }
622 622
623 623
624 void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { 624 void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
625 // Collect type feedback. 625 // Collect type feedback.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 expr->left()->bounds(), expr->right()->bounds(), zone())); 661 expr->left()->bounds(), expr->right()->bounds(), zone()));
662 break; 662 break;
663 } 663 }
664 case Token::BIT_OR: 664 case Token::BIT_OR:
665 case Token::BIT_AND: { 665 case Token::BIT_AND: {
666 RECURSE(Visit(expr->left())); 666 RECURSE(Visit(expr->left()));
667 RECURSE(Visit(expr->right())); 667 RECURSE(Visit(expr->right()));
668 Type* upper = Type::Union( 668 Type* upper = Type::Union(
669 expr->left()->bounds().upper, expr->right()->bounds().upper, zone()); 669 expr->left()->bounds().upper, expr->right()->bounds().upper, zone());
670 if (!upper->Is(Type::Signed32())) upper = Type::Signed32(zone()); 670 if (!upper->Is(Type::Signed32())) upper = Type::Signed32(zone());
671 Type* lower = Type::Intersect(Type::Smi(zone()), upper, zone()); 671 Type* lower = Type::Intersect(Type::SignedSmall(zone()), upper, zone());
672 NarrowType(expr, Bounds(lower, upper)); 672 NarrowType(expr, Bounds(lower, upper));
673 break; 673 break;
674 } 674 }
675 case Token::BIT_XOR: 675 case Token::BIT_XOR:
676 case Token::SHL: 676 case Token::SHL:
677 case Token::SAR: 677 case Token::SAR:
678 RECURSE(Visit(expr->left())); 678 RECURSE(Visit(expr->left()));
679 RECURSE(Visit(expr->right())); 679 RECURSE(Visit(expr->right()));
680 NarrowType(expr, Bounds(Type::Smi(zone()), Type::Signed32(zone()))); 680 NarrowType(expr,
681 Bounds(Type::SignedSmall(zone()), Type::Signed32(zone())));
681 break; 682 break;
682 case Token::SHR: 683 case Token::SHR:
683 RECURSE(Visit(expr->left())); 684 RECURSE(Visit(expr->left()));
684 RECURSE(Visit(expr->right())); 685 RECURSE(Visit(expr->right()));
685 // TODO(rossberg): The upper bound would be Unsigned32, but since there 686 // TODO(rossberg): The upper bound would be Unsigned32, but since there
686 // is no 'positive Smi' type for the lower bound, we use the smallest 687 // is no 'positive Smi' type for the lower bound, we use the smallest
687 // union of Smi and Unsigned32 as upper bound instead. 688 // union of Smi and Unsigned32 as upper bound instead.
688 NarrowType(expr, Bounds(Type::Smi(zone()), Type::Number(zone()))); 689 NarrowType(expr, Bounds(Type::SignedSmall(zone()), Type::Number(zone())));
689 break; 690 break;
690 case Token::ADD: { 691 case Token::ADD: {
691 RECURSE(Visit(expr->left())); 692 RECURSE(Visit(expr->left()));
692 RECURSE(Visit(expr->right())); 693 RECURSE(Visit(expr->right()));
693 Bounds l = expr->left()->bounds(); 694 Bounds l = expr->left()->bounds();
694 Bounds r = expr->right()->bounds(); 695 Bounds r = expr->right()->bounds();
695 Type* lower = 696 Type* lower =
696 l.lower->Is(Type::None()) || r.lower->Is(Type::None()) ? 697 l.lower->Is(Type::None()) || r.lower->Is(Type::None()) ?
697 Type::None(zone()) : 698 Type::None(zone()) :
698 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ? 699 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ?
699 Type::String(zone()) : 700 Type::String(zone()) :
700 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ? 701 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ?
701 Type::Smi(zone()) : Type::None(zone()); 702 Type::SignedSmall(zone()) : Type::None(zone());
702 Type* upper = 703 Type* upper =
703 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ? 704 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ?
704 Type::String(zone()) : 705 Type::String(zone()) :
705 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ? 706 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ?
706 Type::Number(zone()) : Type::NumberOrString(zone()); 707 Type::Number(zone()) : Type::NumberOrString(zone());
707 NarrowType(expr, Bounds(lower, upper)); 708 NarrowType(expr, Bounds(lower, upper));
708 break; 709 break;
709 } 710 }
710 case Token::SUB: 711 case Token::SUB:
711 case Token::MUL: 712 case Token::MUL:
712 case Token::DIV: 713 case Token::DIV:
713 case Token::MOD: 714 case Token::MOD:
714 RECURSE(Visit(expr->left())); 715 RECURSE(Visit(expr->left()));
715 RECURSE(Visit(expr->right())); 716 RECURSE(Visit(expr->right()));
716 NarrowType(expr, Bounds(Type::Smi(zone()), Type::Number(zone()))); 717 NarrowType(expr, Bounds(Type::SignedSmall(zone()), Type::Number(zone())));
717 break; 718 break;
718 default: 719 default:
719 UNREACHABLE(); 720 UNREACHABLE();
720 } 721 }
721 } 722 }
722 723
723 724
724 void AstTyper::VisitCompareOperation(CompareOperation* expr) { 725 void AstTyper::VisitCompareOperation(CompareOperation* expr) {
725 // Collect type feedback. 726 // Collect type feedback.
726 Type* left_type; 727 Type* left_type;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 void AstTyper::VisitModuleUrl(ModuleUrl* module) { 792 void AstTyper::VisitModuleUrl(ModuleUrl* module) {
792 } 793 }
793 794
794 795
795 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { 796 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) {
796 RECURSE(Visit(stmt->body())); 797 RECURSE(Visit(stmt->body()));
797 } 798 }
798 799
799 800
800 } } // namespace v8::internal 801 } } // namespace v8::internal
OLDNEW
« src/types.h ('K') | « src/types.cc ('k') | test/cctest/test-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698