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/conversions.h

Issue 296213005: Various extensions to types (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 | « no previous file | src/hydrogen.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 #ifndef V8_CONVERSIONS_H_ 5 #ifndef V8_CONVERSIONS_H_
6 #define V8_CONVERSIONS_H_ 6 #define V8_CONVERSIONS_H_
7 7
8 #include <limits> 8 #include <limits>
9 9
10 #include "checks.h" 10 #include "checks.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // integer. It has to be in the range [-2^31, 2^31 - 1]. 156 // integer. It has to be in the range [-2^31, 2^31 - 1].
157 // We also have to check for negative 0 as it is not an Integer32. 157 // We also have to check for negative 0 as it is not an Integer32.
158 static inline bool IsInt32Double(double value) { 158 static inline bool IsInt32Double(double value) {
159 return !IsMinusZero(value) && 159 return !IsMinusZero(value) &&
160 value >= kMinInt && 160 value >= kMinInt &&
161 value <= kMaxInt && 161 value <= kMaxInt &&
162 value == FastI2D(FastD2I(value)); 162 value == FastI2D(FastD2I(value));
163 } 163 }
164 164
165 165
166 // UInteger32 is an integer that can be represented as an unsigned 32-bit
167 // integer. It has to be in the range [0, 2^32 - 1].
168 // We also have to check for negative 0 as it is not a UInteger32.
169 static inline bool IsUint32Double(double value) {
170 return !IsMinusZero(value) &&
171 value >= 0 &&
172 value <= kMaxUInt32 &&
173 value == FastUI2D(FastD2UI(value));
174 }
175
176
166 // Convert from Number object to C integer. 177 // Convert from Number object to C integer.
167 inline int32_t NumberToInt32(Object* number) { 178 inline int32_t NumberToInt32(Object* number) {
168 if (number->IsSmi()) return Smi::cast(number)->value(); 179 if (number->IsSmi()) return Smi::cast(number)->value();
169 return DoubleToInt32(number->Number()); 180 return DoubleToInt32(number->Number());
170 } 181 }
171 182
172 183
173 inline uint32_t NumberToUint32(Object* number) { 184 inline uint32_t NumberToUint32(Object* number) {
174 if (number->IsSmi()) return Smi::cast(number)->value(); 185 if (number->IsSmi()) return Smi::cast(number)->value();
175 return DoubleToUint32(number->Number()); 186 return DoubleToUint32(number->Number());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 Object* number) { 223 Object* number) {
213 size_t result = 0; 224 size_t result = 0;
214 bool is_valid = TryNumberToSize(isolate, number, &result); 225 bool is_valid = TryNumberToSize(isolate, number, &result);
215 CHECK(is_valid); 226 CHECK(is_valid);
216 return result; 227 return result;
217 } 228 }
218 229
219 } } // namespace v8::internal 230 } } // namespace v8::internal
220 231
221 #endif // V8_CONVERSIONS_H_ 232 #endif // V8_CONVERSIONS_H_
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698