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

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

Issue 602693002: Give more precise types to some Math functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
« no previous file with comments | « src/compiler/typer.h ('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/compiler/graph-inl.h" 5 #include "src/compiler/graph-inl.h"
6 #include "src/compiler/js-operator.h" 6 #include "src/compiler/js-operator.h"
7 #include "src/compiler/node.h" 7 #include "src/compiler/node.h"
8 #include "src/compiler/node-properties-inl.h" 8 #include "src/compiler/node-properties-inl.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 #include "src/compiler/simplified-operator.h" 10 #include "src/compiler/simplified-operator.h"
11 #include "src/compiler/typer.h" 11 #include "src/compiler/typer.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 namespace compiler { 15 namespace compiler {
16 16
17 Typer::Typer(Zone* zone) : zone_(zone) { 17 Typer::Typer(Zone* zone) : zone_(zone) {
18 Type* number = Type::Number(zone); 18 Factory* f = zone->isolate()->factory();
19 Type* signed32 = Type::Signed32(zone); 19
20 Type* unsigned32 = Type::Unsigned32(zone); 20 Type* number = Type::Number();
21 Type* integral32 = Type::Integral32(zone); 21 Type* signed32 = Type::Signed32();
22 Type* object = Type::Object(zone); 22 Type* unsigned32 = Type::Unsigned32();
23 Type* undefined = Type::Undefined(zone); 23 Type* integral32 = Type::Integral32();
24 Type* object = Type::Object();
25 Type* undefined = Type::Undefined();
26 Type* weakint = Type::Union(
27 Type::Range(f->NewNumber(-V8_INFINITY), f->NewNumber(+V8_INFINITY), zone),
28 Type::Union(Type::NaN(), Type::MinusZero(), zone), zone);
29
24 number_fun0_ = Type::Function(number, zone); 30 number_fun0_ = Type::Function(number, zone);
25 number_fun1_ = Type::Function(number, number, zone); 31 number_fun1_ = Type::Function(number, number, zone);
26 number_fun2_ = Type::Function(number, number, number, zone); 32 number_fun2_ = Type::Function(number, number, number, zone);
33 weakint_fun1_ = Type::Function(weakint, number, zone);
27 imul_fun_ = Type::Function(signed32, integral32, integral32, zone); 34 imul_fun_ = Type::Function(signed32, integral32, integral32, zone);
35 random_fun_ = Type::Function(Type::Union(
36 Type::UnsignedSmall(), Type::OtherNumber(), zone), zone);
37
28 38
29 #define NATIVE_TYPE(sem, rep) \ 39 #define NATIVE_TYPE(sem, rep) \
30 Type::Intersect(Type::sem(zone), Type::rep(zone), zone) 40 Type::Intersect(Type::sem(zone), Type::rep(zone), zone)
31 // TODO(rossberg): Use range types for more precision, once we have them. 41 // TODO(rossberg): Use range types for more precision, once we have them.
32 Type* int8 = NATIVE_TYPE(SignedSmall, UntaggedInt8); 42 Type* int8 = NATIVE_TYPE(SignedSmall, UntaggedInt8);
33 Type* int16 = NATIVE_TYPE(SignedSmall, UntaggedInt16); 43 Type* int16 = NATIVE_TYPE(SignedSmall, UntaggedInt16);
34 Type* int32 = NATIVE_TYPE(Signed32, UntaggedInt32); 44 Type* int32 = NATIVE_TYPE(Signed32, UntaggedInt32);
35 Type* uint8 = NATIVE_TYPE(UnsignedSmall, UntaggedInt8); 45 Type* uint8 = NATIVE_TYPE(UnsignedSmall, UntaggedInt8);
36 Type* uint16 = NATIVE_TYPE(UnsignedSmall, UntaggedInt16); 46 Type* uint16 = NATIVE_TYPE(UnsignedSmall, UntaggedInt16);
37 Type* uint32 = NATIVE_TYPE(Unsigned32, UntaggedInt32); 47 Type* uint32 = NATIVE_TYPE(Unsigned32, UntaggedInt32);
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 return typer_->number_fun1_; // TODO(rossberg): can't express overloading 837 return typer_->number_fun1_; // TODO(rossberg): can't express overloading
828 } else if (*value == native->math_acos_fun()) { 838 } else if (*value == native->math_acos_fun()) {
829 return typer_->number_fun1_; 839 return typer_->number_fun1_;
830 } else if (*value == native->math_asin_fun()) { 840 } else if (*value == native->math_asin_fun()) {
831 return typer_->number_fun1_; 841 return typer_->number_fun1_;
832 } else if (*value == native->math_atan_fun()) { 842 } else if (*value == native->math_atan_fun()) {
833 return typer_->number_fun1_; 843 return typer_->number_fun1_;
834 } else if (*value == native->math_atan2_fun()) { 844 } else if (*value == native->math_atan2_fun()) {
835 return typer_->number_fun2_; 845 return typer_->number_fun2_;
836 } else if (*value == native->math_ceil_fun()) { 846 } else if (*value == native->math_ceil_fun()) {
837 return typer_->number_fun1_; 847 return typer_->weakint_fun1_;
838 } else if (*value == native->math_cos_fun()) { 848 } else if (*value == native->math_cos_fun()) {
839 return typer_->number_fun1_; 849 return typer_->number_fun1_;
840 } else if (*value == native->math_exp_fun()) { 850 } else if (*value == native->math_exp_fun()) {
841 return typer_->number_fun1_; 851 return typer_->number_fun1_;
842 } else if (*value == native->math_floor_fun()) { 852 } else if (*value == native->math_floor_fun()) {
843 return typer_->number_fun1_; 853 return typer_->weakint_fun1_;
844 } else if (*value == native->math_imul_fun()) { 854 } else if (*value == native->math_imul_fun()) {
845 return typer_->imul_fun_; 855 return typer_->imul_fun_;
846 } else if (*value == native->math_log_fun()) { 856 } else if (*value == native->math_log_fun()) {
847 return typer_->number_fun1_; 857 return typer_->number_fun1_;
848 } else if (*value == native->math_pow_fun()) { 858 } else if (*value == native->math_pow_fun()) {
849 return typer_->number_fun2_; 859 return typer_->number_fun2_;
850 } else if (*value == native->math_random_fun()) { 860 } else if (*value == native->math_random_fun()) {
851 return typer_->number_fun0_; 861 return typer_->random_fun_;
852 } else if (*value == native->math_round_fun()) { 862 } else if (*value == native->math_round_fun()) {
853 return typer_->number_fun1_; 863 return typer_->weakint_fun1_;
854 } else if (*value == native->math_sin_fun()) { 864 } else if (*value == native->math_sin_fun()) {
855 return typer_->number_fun1_; 865 return typer_->number_fun1_;
856 } else if (*value == native->math_sqrt_fun()) { 866 } else if (*value == native->math_sqrt_fun()) {
857 return typer_->number_fun1_; 867 return typer_->number_fun1_;
858 } else if (*value == native->math_tan_fun()) { 868 } else if (*value == native->math_tan_fun()) {
859 return typer_->number_fun1_; 869 return typer_->number_fun1_;
860 } else if (*value == native->array_buffer_fun()) { 870 } else if (*value == native->array_buffer_fun()) {
861 return typer_->array_buffer_fun_; 871 return typer_->array_buffer_fun_;
862 } else if (*value == native->int8_array_fun()) { 872 } else if (*value == native->int8_array_fun()) {
863 return typer_->int8_array_fun_; 873 return typer_->int8_array_fun_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 } 905 }
896 906
897 907
898 void Typer::DecorateGraph(Graph* graph) { 908 void Typer::DecorateGraph(Graph* graph) {
899 graph->AddDecorator(new (zone()) TyperDecorator(this)); 909 graph->AddDecorator(new (zone()) TyperDecorator(this));
900 } 910 }
901 911
902 } 912 }
903 } 913 }
904 } // namespace v8::internal::compiler 914 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « src/compiler/typer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698