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

Side by Side Diff: src/compiler/typer.cc

Issue 711923003: [WIP] Faster smi tagging. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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/compiler/change-lowering.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 #include "src/compiler/graph-inl.h" 6 #include "src/compiler/graph-inl.h"
7 #include "src/compiler/js-operator.h" 7 #include "src/compiler/js-operator.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/compiler/node-properties-inl.h" 9 #include "src/compiler/node-properties-inl.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 732
733 733
734 Type* Typer::Visitor::JSBitwiseAndTyper(Type* lhs, Type* rhs, Typer* t) { 734 Type* Typer::Visitor::JSBitwiseAndTyper(Type* lhs, Type* rhs, Typer* t) {
735 Factory* f = t->isolate()->factory(); 735 Factory* f = t->isolate()->factory();
736 lhs = NumberToInt32(ToNumber(lhs, t), t); 736 lhs = NumberToInt32(ToNumber(lhs, t), t);
737 rhs = NumberToInt32(ToNumber(rhs, t), t); 737 rhs = NumberToInt32(ToNumber(rhs, t), t);
738 double lmin = lhs->Min(); 738 double lmin = lhs->Min();
739 double rmin = rhs->Min(); 739 double rmin = rhs->Min();
740 double lmax = lhs->Max(); 740 double lmax = lhs->Max();
741 double rmax = rhs->Max(); 741 double rmax = rhs->Max();
742 if (std::min(lmax, rmax) < kMaxInt) {
743 Handle<Object> min = f->NewNumber(0);
744 Handle<Object> max = f->NewNumber(std::min(lmax, rmax));
745 return Type::Range(min, max, t->zone());
746 }
742 // And-ing any two values results in a value no larger than their maximum. 747 // And-ing any two values results in a value no larger than their maximum.
743 // Even no larger than their minimum if both values are non-negative. 748 // Even no larger than their minimum if both values are non-negative.
744 Handle<Object> max = f->NewNumber( 749 Handle<Object> max = f->NewNumber(
745 lmin >= 0 && rmin >= 0 ? std::min(lmax, rmax) : std::max(lmax, rmax)); 750 lmin >= 0 && rmin >= 0 ? std::min(lmax, rmax) : std::max(lmax, rmax));
746 if (lmin >= 0 || rmin >= 0) { 751 if (lmin >= 0 || rmin >= 0) {
747 // And-ing two values of which at least one is non-negative results in a 752 // And-ing two values of which at least one is non-negative results in a
748 // non-negative value. 753 // non-negative value.
749 Handle<Object> min = f->NewNumber(0); 754 Handle<Object> min = f->NewNumber(0);
750 return Type::Range(min, max, t->zone()); 755 return Type::Range(min, max, t->zone());
751 } 756 }
(...skipping 21 matching lines...) Expand all
773 } 778 }
774 779
775 780
776 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) { 781 Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) {
777 return Type::Signed32(); 782 return Type::Signed32();
778 } 783 }
779 784
780 785
781 Type* Typer::Visitor::JSShiftRightTyper(Type* lhs, Type* rhs, Typer* t) { 786 Type* Typer::Visitor::JSShiftRightTyper(Type* lhs, Type* rhs, Typer* t) {
782 lhs = NumberToInt32(ToNumber(lhs, t), t); 787 lhs = NumberToInt32(ToNumber(lhs, t), t);
788 rhs = NumberToInt32(ToNumber(rhs, t), t);
783 Factory* f = t->isolate()->factory(); 789 Factory* f = t->isolate()->factory();
784 if (lhs->Min() >= 0) { 790 if (lhs->Min() >= 0) {
785 // Right-shifting a non-negative value cannot make it negative, nor larger. 791 // Right-shifting a non-negative value cannot make it negative, nor larger.
786 Handle<Object> min = f->NewNumber(0); 792 Handle<Object> min = f->NewNumber(0);
787 Handle<Object> max = f->NewNumber(lhs->Max()); 793 Handle<Object> max = f->NewNumber(lhs->Max());
788 return Type::Range(min, max, t->zone()); 794 return Type::Range(min, max, t->zone());
789 } 795 }
790 if (lhs->Max() < 0) { 796 if (lhs->Max() < 0) {
791 // Right-shifting a negative value cannot make it non-negative, nor smaller. 797 // Right-shifting a negative value cannot make it non-negative, nor smaller.
792 Handle<Object> min = f->NewNumber(lhs->Min()); 798 Handle<Object> min = f->NewNumber(lhs->Min());
793 Handle<Object> max = f->NewNumber(-1); 799 Handle<Object> max = f->NewNumber(-1);
794 return Type::Range(min, max, t->zone()); 800 return Type::Range(min, max, t->zone());
795 } 801 }
802 if (rhs->Min() > 0) {
803 // Right-shifting by a positve value yields a small integer value.
804 Handle<Object> min = f->NewNumber(kMinInt >> static_cast<int>(rhs->Min()));
805 Handle<Object> max = f->NewNumber(kMaxInt >> static_cast<int>(rhs->Min()));
806 return Type::Range(min, max, t->zone());
807 }
796 return Type::Signed32(); 808 return Type::Signed32();
797 } 809 }
798 810
799 811
800 Type* Typer::Visitor::JSShiftRightLogicalTyper(Type* lhs, Type* rhs, Typer* t) { 812 Type* Typer::Visitor::JSShiftRightLogicalTyper(Type* lhs, Type* rhs, Typer* t) {
801 lhs = NumberToUint32(ToNumber(lhs, t), t); 813 lhs = NumberToUint32(ToNumber(lhs, t), t);
802 Factory* f = t->isolate()->factory(); 814 Factory* f = t->isolate()->factory();
803 // Logical right-shifting any value cannot make it larger. 815 // Logical right-shifting any value cannot make it larger.
804 Handle<Object> min = f->NewNumber(0); 816 Handle<Object> min = f->NewNumber(0);
805 Handle<Object> max = f->NewNumber(lhs->Max()); 817 Handle<Object> max = f->NewNumber(lhs->Max());
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 return typer_->float64_array_fun_; 1945 return typer_->float64_array_fun_;
1934 } 1946 }
1935 } 1947 }
1936 } 1948 }
1937 return Type::Constant(value, zone()); 1949 return Type::Constant(value, zone());
1938 } 1950 }
1939 1951
1940 } 1952 }
1941 } 1953 }
1942 } // namespace v8::internal::compiler 1954 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « src/compiler/change-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698