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

Side by Side Diff: src/type-info.h

Issue 3151017: Make the Integer32 type info only cover the signed 32 bit integers.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 4 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/ia32/macro-assembler-ia32.cc ('k') | test/mjsunit/bitops-info.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 class TypeInfo { 48 class TypeInfo {
49 public: 49 public:
50 TypeInfo() : type_(kUnknownType) { } 50 TypeInfo() : type_(kUnknownType) { }
51 51
52 static inline TypeInfo Unknown(); 52 static inline TypeInfo Unknown();
53 // We know it's a primitive type. 53 // We know it's a primitive type.
54 static inline TypeInfo Primitive(); 54 static inline TypeInfo Primitive();
55 // We know it's a number of some sort. 55 // We know it's a number of some sort.
56 static inline TypeInfo Number(); 56 static inline TypeInfo Number();
57 // We know it's signed or unsigned 32 bit integer. 57 // We know it's signed 32 bit integer.
58 static inline TypeInfo Integer32(); 58 static inline TypeInfo Integer32();
59 // We know it's a Smi. 59 // We know it's a Smi.
60 static inline TypeInfo Smi(); 60 static inline TypeInfo Smi();
61 // We know it's a heap number. 61 // We know it's a heap number.
62 static inline TypeInfo Double(); 62 static inline TypeInfo Double();
63 // We know it's a string. 63 // We know it's a string.
64 static inline TypeInfo String(); 64 static inline TypeInfo String();
65 // We haven't started collecting info yet. 65 // We haven't started collecting info yet.
66 static inline TypeInfo Uninitialized(); 66 static inline TypeInfo Uninitialized();
67 67
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 t == kStringType); 106 t == kStringType);
107 return TypeInfo(t); 107 return TypeInfo(t);
108 } 108 }
109 109
110 // Return the weakest (least precise) common type. 110 // Return the weakest (least precise) common type.
111 static TypeInfo Combine(TypeInfo a, TypeInfo b) { 111 static TypeInfo Combine(TypeInfo a, TypeInfo b) {
112 return TypeInfo(static_cast<Type>(a.type_ & b.type_)); 112 return TypeInfo(static_cast<Type>(a.type_ & b.type_));
113 } 113 }
114 114
115 115
116 // Integer32 is an integer that can be represented as either a signed 116 // Integer32 is an integer that can be represented as a signed
117 // 32-bit integer or as an unsigned 32-bit integer. It has to be 117 // 32-bit integer. It has to be in the range [-2^31, 2^31 - 1].
118 // in the range [-2^31, 2^32 - 1]. We also have to check for negative 0 118 // We also have to check for negative 0 as it is not an Integer32.
119 // as it is not an Integer32.
120 static inline bool IsInt32Double(double value) { 119 static inline bool IsInt32Double(double value) {
121 const DoubleRepresentation minus_zero(-0.0); 120 const DoubleRepresentation minus_zero(-0.0);
122 DoubleRepresentation rep(value); 121 DoubleRepresentation rep(value);
123 if (rep.bits == minus_zero.bits) return false; 122 if (rep.bits == minus_zero.bits) return false;
124 if (value >= kMinInt && value <= kMaxUInt32) { 123 if (value >= kMinInt && value <= kMaxInt) {
125 if (value <= kMaxInt && value == static_cast<int32_t>(value)) { 124 if (value == static_cast<int32_t>(value)) return true;
126 return true;
127 }
128 if (value == static_cast<uint32_t>(value)) return true;
129 } 125 }
130 return false; 126 return false;
131 } 127 }
132 128
133 static TypeInfo TypeFromValue(Handle<Object> value); 129 static TypeInfo TypeFromValue(Handle<Object> value);
134 130
135 inline bool IsUnknown() { 131 inline bool IsUnknown() {
136 return type_ == kUnknownType; 132 return type_ == kUnknownType;
137 } 133 }
138 134
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 231 }
236 232
237 233
238 TypeInfo TypeInfo::Uninitialized() { 234 TypeInfo TypeInfo::Uninitialized() {
239 return TypeInfo(kUninitializedType); 235 return TypeInfo(kUninitializedType);
240 } 236 }
241 237
242 } } // namespace v8::internal 238 } } // namespace v8::internal
243 239
244 #endif // V8_TYPE_INFO_H_ 240 #endif // V8_TYPE_INFO_H_
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | test/mjsunit/bitops-info.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698