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

Side by Side Diff: third_party/WebKit/Source/wtf/dtoa/cached-powers.cc

Issue 2640163004: Replace ENABLE(ASSERT) with DCHECK_IS_ON(). (Closed)
Patch Set: m_domTreeVersion initialization Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/wtf/AssertionsTest.cpp ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 {UINT64_2PART_C(0x9e19db92, b4e31ba9), 1013, 324}, 131 {UINT64_2PART_C(0x9e19db92, b4e31ba9), 1013, 324},
132 {UINT64_2PART_C(0xeb96bf6e, badf77d9), 1039, 332}, 132 {UINT64_2PART_C(0xeb96bf6e, badf77d9), 1039, 332},
133 {UINT64_2PART_C(0xaf87023b, 9bf0ee6b), 1066, 340}, 133 {UINT64_2PART_C(0xaf87023b, 9bf0ee6b), 1066, 340},
134 }; 134 };
135 static const int kCachedPowersOffset = 348; // -kCachedPowers[0].decimal_exp onent 135 static const int kCachedPowersOffset = 348; // -kCachedPowers[0].decimal_exp onent
136 136
137 const int PowersOfTenCache::kDecimalExponentDistance = 8; // kCachedPowers[1 ].decimal_exponent - kCachedPowers[0].decimal_exponent 137 const int PowersOfTenCache::kDecimalExponentDistance = 8; // kCachedPowers[1 ].decimal_exponent - kCachedPowers[0].decimal_exponent
138 const int PowersOfTenCache::kMinDecimalExponent = -348; // kCachedPowers[0]. decimal_exponent 138 const int PowersOfTenCache::kMinDecimalExponent = -348; // kCachedPowers[0]. decimal_exponent
139 const int PowersOfTenCache::kMaxDecimalExponent = 340; // kCachedPowers[kCac hedPowersLength - 1].decimal_exponent 139 const int PowersOfTenCache::kMaxDecimalExponent = 340; // kCachedPowers[kCac hedPowersLength - 1].decimal_exponent
140 140
141 #if ENABLE(ASSERT) 141 #if DCHECK_IS_ON()
142 static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers); 142 static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
143 143
144 // Check that the static constants match the values in kCachedPowers. 144 // Check that the static constants match the values in kCachedPowers.
145 static void validateStaticConstants() { 145 static void validateStaticConstants() {
146 ASSERT(kCachedPowersOffset == -kCachedPowers[0].decimal_exponent); 146 ASSERT(kCachedPowersOffset == -kCachedPowers[0].decimal_exponent);
147 ASSERT(PowersOfTenCache::kDecimalExponentDistance == (kCachedPowers[1].d ecimal_exponent - kCachedPowers[0].decimal_exponent)); 147 ASSERT(PowersOfTenCache::kDecimalExponentDistance == (kCachedPowers[1].d ecimal_exponent - kCachedPowers[0].decimal_exponent));
148 ASSERT(PowersOfTenCache::kMinDecimalExponent == kCachedPowers[0].decimal _exponent); 148 ASSERT(PowersOfTenCache::kMinDecimalExponent == kCachedPowers[0].decimal _exponent);
149 ASSERT(PowersOfTenCache::kMaxDecimalExponent == kCachedPowers[kCachedPow ersLength - 1].decimal_exponent); 149 ASSERT(PowersOfTenCache::kMaxDecimalExponent == kCachedPowers[kCachedPow ersLength - 1].decimal_exponent);
150 } 150 }
151 #endif 151 #endif
152 152
153 void PowersOfTenCache::GetCachedPowerForBinaryExponentRange( 153 void PowersOfTenCache::GetCachedPowerForBinaryExponentRange(
154 int min_exponent , 154 int min_exponent ,
155 int max_exponent , 155 int max_exponent ,
156 DiyFp* power, 156 DiyFp* power,
157 int* decimal_exp onent) { 157 int* decimal_exp onent) {
158 #if ENABLE(ASSERT) 158 #if DCHECK_IS_ON()
159 validateStaticConstants(); 159 validateStaticConstants();
160 #endif 160 #endif
161 const int kQ = DiyFp::kSignificandSize; 161 const int kQ = DiyFp::kSignificandSize;
162 double k = ceil((min_exponent + kQ - 1) * kD_1_LOG2_10); 162 double k = ceil((min_exponent + kQ - 1) * kD_1_LOG2_10);
163 int foo = kCachedPowersOffset; 163 int foo = kCachedPowersOffset;
164 int index = 164 int index =
165 (foo + static_cast<int>(k) - 1) / kDecimalExponentDistance + 1; 165 (foo + static_cast<int>(k) - 1) / kDecimalExponentDistance + 1;
166 ASSERT(0 <= index && index < kCachedPowersLength); 166 ASSERT(0 <= index && index < kCachedPowersLength);
167 CachedPower cached_power = kCachedPowers[index]; 167 CachedPower cached_power = kCachedPowers[index];
168 ASSERT(min_exponent <= cached_power.binary_exponent); 168 ASSERT(min_exponent <= cached_power.binary_exponent);
169 ASSERT(cached_power.binary_exponent <= max_exponent); 169 ASSERT(cached_power.binary_exponent <= max_exponent);
170 *decimal_exponent = cached_power.decimal_exponent; 170 *decimal_exponent = cached_power.decimal_exponent;
171 *power = DiyFp(cached_power.significand, cached_power.binary_exponent); 171 *power = DiyFp(cached_power.significand, cached_power.binary_exponent);
172 } 172 }
173 173
174 174
175 void PowersOfTenCache::GetCachedPowerForDecimalExponent(int requested_expone nt, 175 void PowersOfTenCache::GetCachedPowerForDecimalExponent(int requested_expone nt,
176 DiyFp* power, 176 DiyFp* power,
177 int* found_exponent) { 177 int* found_exponent) {
178 ASSERT(kMinDecimalExponent <= requested_exponent); 178 ASSERT(kMinDecimalExponent <= requested_exponent);
179 ASSERT(requested_exponent < kMaxDecimalExponent + kDecimalExponentDistan ce); 179 ASSERT(requested_exponent < kMaxDecimalExponent + kDecimalExponentDistan ce);
180 #if ENABLE(ASSERT) 180 #if DCHECK_IS_ON()
181 validateStaticConstants(); 181 validateStaticConstants();
182 #endif 182 #endif
183 int index = 183 int index =
184 (requested_exponent + kCachedPowersOffset) / kDecimalExponentDistance; 184 (requested_exponent + kCachedPowersOffset) / kDecimalExponentDistance;
185 CachedPower cached_power = kCachedPowers[index]; 185 CachedPower cached_power = kCachedPowers[index];
186 *power = DiyFp(cached_power.significand, cached_power.binary_exponent); 186 *power = DiyFp(cached_power.significand, cached_power.binary_exponent);
187 *found_exponent = cached_power.decimal_exponent; 187 *found_exponent = cached_power.decimal_exponent;
188 ASSERT(*found_exponent <= requested_exponent); 188 ASSERT(*found_exponent <= requested_exponent);
189 ASSERT(requested_exponent < *found_exponent + kDecimalExponentDistance); 189 ASSERT(requested_exponent < *found_exponent + kDecimalExponentDistance);
190 } 190 }
191 191
192 } // namespace double_conversion 192 } // namespace double_conversion
193 193
194 } // namespace WTF 194 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/AssertionsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698