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

Side by Side Diff: src/types.cc

Issue 813813003: Revert of Remove obsolete V8_INFINITY macro. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/strtod.cc ('k') | test/cctest/compiler/codegen-tester.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 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 <iomanip>
6
5 #include "src/types.h" 7 #include "src/types.h"
6 8
7 #include <iomanip>
8 #include <limits>
9
10 #include "src/ostreams.h" 9 #include "src/ostreams.h"
11 #include "src/types-inl.h" 10 #include "src/types-inl.h"
12 11
13 namespace v8 { 12 namespace v8 {
14 namespace internal { 13 namespace internal {
15 14
16 15
17 // NOTE: If code is marked as being a "shortcut", this means that removing 16 // NOTE: If code is marked as being a "shortcut", this means that removing
18 // the code won't affect the semantics of the surrounding function definition. 17 // the code won't affect the semantics of the surrounding function definition.
19 18
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 74
76 75
77 // ----------------------------------------------------------------------------- 76 // -----------------------------------------------------------------------------
78 // Min and Max computation. 77 // Min and Max computation.
79 78
80 template<class Config> 79 template<class Config>
81 double TypeImpl<Config>::Min() { 80 double TypeImpl<Config>::Min() {
82 DCHECK(this->Is(Number())); 81 DCHECK(this->Is(Number()));
83 if (this->IsBitset()) return BitsetType::Min(this->AsBitset()); 82 if (this->IsBitset()) return BitsetType::Min(this->AsBitset());
84 if (this->IsUnion()) { 83 if (this->IsUnion()) {
85 double min = +std::numeric_limits<double>::infinity(); 84 double min = +V8_INFINITY;
86 for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) { 85 for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
87 min = std::min(min, this->AsUnion()->Get(i)->Min()); 86 min = std::min(min, this->AsUnion()->Get(i)->Min());
88 } 87 }
89 return min; 88 return min;
90 } 89 }
91 if (this->IsRange()) return this->AsRange()->Min()->Number(); 90 if (this->IsRange()) return this->AsRange()->Min()->Number();
92 if (this->IsConstant()) return this->AsConstant()->Value()->Number(); 91 if (this->IsConstant()) return this->AsConstant()->Value()->Number();
93 UNREACHABLE(); 92 UNREACHABLE();
94 return 0; 93 return 0;
95 } 94 }
96 95
97 96
98 template<class Config> 97 template<class Config>
99 double TypeImpl<Config>::Max() { 98 double TypeImpl<Config>::Max() {
100 DCHECK(this->Is(Number())); 99 DCHECK(this->Is(Number()));
101 if (this->IsBitset()) return BitsetType::Max(this->AsBitset()); 100 if (this->IsBitset()) return BitsetType::Max(this->AsBitset());
102 if (this->IsUnion()) { 101 if (this->IsUnion()) {
103 double max = -std::numeric_limits<double>::infinity(); 102 double max = -V8_INFINITY;
104 for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) { 103 for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
105 max = std::max(max, this->AsUnion()->Get(i)->Max()); 104 max = std::max(max, this->AsUnion()->Get(i)->Max());
106 } 105 }
107 return max; 106 return max;
108 } 107 }
109 if (this->IsRange()) return this->AsRange()->Max()->Number(); 108 if (this->IsRange()) return this->AsRange()->Max()->Number();
110 if (this->IsConstant()) return this->AsConstant()->Value()->Number(); 109 if (this->IsConstant()) return this->AsConstant()->Value()->Number();
111 UNREACHABLE(); 110 UNREACHABLE();
112 return 0; 111 return 0;
113 } 112 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (std::isnan(value)) return kNaN; 280 if (std::isnan(value)) return kNaN;
282 if (IsUint32Double(value) || IsInt32Double(value)) return Lub(value, value); 281 if (IsUint32Double(value) || IsInt32Double(value)) return Lub(value, value);
283 return kPlainNumber; 282 return kPlainNumber;
284 } 283 }
285 284
286 285
287 // Minimum values of regular numeric bitsets when SmiValuesAre31Bits. 286 // Minimum values of regular numeric bitsets when SmiValuesAre31Bits.
288 template <class Config> 287 template <class Config>
289 const typename TypeImpl<Config>::BitsetType::BitsetMin 288 const typename TypeImpl<Config>::BitsetType::BitsetMin
290 TypeImpl<Config>::BitsetType::BitsetMins31[] = { 289 TypeImpl<Config>::BitsetType::BitsetMins31[] = {
291 {kOtherNumber, -std::numeric_limits<double>::infinity()}, 290 {kOtherNumber, -V8_INFINITY},
292 {kOtherSigned32, kMinInt}, 291 {kOtherSigned32, kMinInt},
293 {kNegativeSignedSmall, -0x40000000}, 292 {kNegativeSignedSmall, -0x40000000},
294 {kUnsignedSmall, 0}, 293 {kUnsignedSmall, 0},
295 {kOtherUnsigned31, 0x40000000}, 294 {kOtherUnsigned31, 0x40000000},
296 {kOtherUnsigned32, 0x80000000}, 295 {kOtherUnsigned32, 0x80000000},
297 {kOtherNumber, static_cast<double>(kMaxUInt32) + 1}}; 296 {kOtherNumber, static_cast<double>(kMaxUInt32) + 1}};
298 297
299 298
300 // Minimum values of regular numeric bitsets when SmiValuesAre32Bits. 299 // Minimum values of regular numeric bitsets when SmiValuesAre32Bits.
301 // OtherSigned32 and OtherUnsigned31 are empty (see the diagrams in types.h). 300 // OtherSigned32 and OtherUnsigned31 are empty (see the diagrams in types.h).
302 template <class Config> 301 template <class Config>
303 const typename TypeImpl<Config>::BitsetType::BitsetMin 302 const typename TypeImpl<Config>::BitsetType::BitsetMin
304 TypeImpl<Config>::BitsetType::BitsetMins32[] = { 303 TypeImpl<Config>::BitsetType::BitsetMins32[] = {
305 {kOtherNumber, -std::numeric_limits<double>::infinity()}, 304 {kOtherNumber, -V8_INFINITY},
306 {kNegativeSignedSmall, kMinInt}, 305 {kNegativeSignedSmall, kMinInt},
307 {kUnsignedSmall, 0}, 306 {kUnsignedSmall, 0},
308 {kOtherUnsigned32, 0x80000000}, 307 {kOtherUnsigned32, 0x80000000},
309 {kOtherNumber, static_cast<double>(kMaxUInt32) + 1}}; 308 {kOtherNumber, static_cast<double>(kMaxUInt32) + 1}};
310 309
311 310
312 template<class Config> 311 template<class Config>
313 typename TypeImpl<Config>::bitset 312 typename TypeImpl<Config>::bitset
314 TypeImpl<Config>::BitsetType::Lub(double min, double max) { 313 TypeImpl<Config>::BitsetType::Lub(double min, double max) {
315 DisallowHeapAllocation no_allocation; 314 DisallowHeapAllocation no_allocation;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 346 }
348 347
349 348
350 template<class Config> 349 template<class Config>
351 double TypeImpl<Config>::BitsetType::Max(bitset bits) { 350 double TypeImpl<Config>::BitsetType::Max(bitset bits) {
352 DisallowHeapAllocation no_allocation; 351 DisallowHeapAllocation no_allocation;
353 DCHECK(Is(bits, kNumber)); 352 DCHECK(Is(bits, kNumber));
354 const BitsetMin* mins = BitsetMins(); 353 const BitsetMin* mins = BitsetMins();
355 bool mz = SEMANTIC(bits & kMinusZero); 354 bool mz = SEMANTIC(bits & kMinusZero);
356 if (BitsetType::Is(mins[BitsetMinsSize()-1].bits, bits)) { 355 if (BitsetType::Is(mins[BitsetMinsSize()-1].bits, bits)) {
357 return +std::numeric_limits<double>::infinity(); 356 return +V8_INFINITY;
358 } 357 }
359 for (size_t i = BitsetMinsSize()-1; i-- > 0; ) { 358 for (size_t i = BitsetMinsSize()-1; i-- > 0; ) {
360 if (Is(SEMANTIC(mins[i].bits), bits)) { 359 if (Is(SEMANTIC(mins[i].bits), bits)) {
361 return mz ? 360 return mz ?
362 std::max(0.0, mins[i+1].min - 1) : mins[i+1].min - 1; 361 std::max(0.0, mins[i+1].min - 1) : mins[i+1].min - 1;
363 } 362 }
364 } 363 }
365 if (mz) return 0; 364 if (mz) return 0;
366 return base::OS::nan_value(); 365 return base::OS::nan_value();
367 } 366 }
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; 1097 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>;
1099 1098
1100 template TypeImpl<ZoneTypeConfig>::TypeHandle 1099 template TypeImpl<ZoneTypeConfig>::TypeHandle
1101 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( 1100 TypeImpl<ZoneTypeConfig>::Convert<HeapType>(
1102 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); 1101 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*);
1103 template TypeImpl<HeapTypeConfig>::TypeHandle 1102 template TypeImpl<HeapTypeConfig>::TypeHandle
1104 TypeImpl<HeapTypeConfig>::Convert<Type>( 1103 TypeImpl<HeapTypeConfig>::Convert<Type>(
1105 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); 1104 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*);
1106 1105
1107 } } // namespace v8::internal 1106 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/strtod.cc ('k') | test/cctest/compiler/codegen-tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698