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

Side by Side Diff: src/objects-inl.h

Issue 863633002: Use signaling NaN for holes in fixed double arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Next bunch of fixes Created 5 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map()); 2282 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map());
2283 DCHECK_EQ(FIXED_ARRAY_TYPE, map()->instance_type()); 2283 DCHECK_EQ(FIXED_ARRAY_TYPE, map()->instance_type());
2284 DCHECK(index >= 0 && index < this->length()); 2284 DCHECK(index >= 0 && index < this->length());
2285 int offset = kHeaderSize + index * kPointerSize; 2285 int offset = kHeaderSize + index * kPointerSize;
2286 WRITE_FIELD(this, offset, value); 2286 WRITE_FIELD(this, offset, value);
2287 WRITE_BARRIER(GetHeap(), this, offset, value); 2287 WRITE_BARRIER(GetHeap(), this, offset, value);
2288 } 2288 }
2289 2289
2290 2290
2291 inline bool FixedDoubleArray::is_the_hole_nan(double value) { 2291 inline bool FixedDoubleArray::is_the_hole_nan(double value) {
2292 return bit_cast<uint64_t, double>(value) == kHoleNanInt64; 2292 return bit_cast<uint64_t>(value) == kHoleNanInt64;
2293 } 2293 }
2294 2294
2295 2295
2296 inline double FixedDoubleArray::hole_nan_as_double() { 2296 inline double FixedDoubleArray::hole_nan_as_double() {
2297 return bit_cast<double, uint64_t>(kHoleNanInt64); 2297 return bit_cast<double>(kHoleNanInt64);
2298 } 2298 }
2299 2299
2300 2300
2301 inline double FixedDoubleArray::canonical_not_the_hole_nan_as_double() {
2302 DCHECK(bit_cast<uint64_t>(base::OS::nan_value()) != kHoleNanInt64);
2303 DCHECK((bit_cast<uint64_t>(base::OS::nan_value()) >> 32) != kHoleNanUpper32);
2304 return base::OS::nan_value();
2305 }
2306
2307
2308 double FixedDoubleArray::get_scalar(int index) { 2301 double FixedDoubleArray::get_scalar(int index) {
2309 DCHECK(map() != GetHeap()->fixed_cow_array_map() && 2302 DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
2310 map() != GetHeap()->fixed_array_map()); 2303 map() != GetHeap()->fixed_array_map());
2311 DCHECK(index >= 0 && index < this->length()); 2304 DCHECK(index >= 0 && index < this->length());
2312 double result = READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize); 2305 double result = READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize);
2313 DCHECK(!is_the_hole_nan(result)); 2306 DCHECK(!is_the_hole_nan(result));
2314 return result; 2307 return result;
2315 } 2308 }
2316 2309
2317 int64_t FixedDoubleArray::get_representation(int index) { 2310 int64_t FixedDoubleArray::get_representation(int index) {
(...skipping 11 matching lines...) Expand all
2329 } else { 2322 } else {
2330 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index)); 2323 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index));
2331 } 2324 }
2332 } 2325 }
2333 2326
2334 2327
2335 void FixedDoubleArray::set(int index, double value) { 2328 void FixedDoubleArray::set(int index, double value) {
2336 DCHECK(map() != GetHeap()->fixed_cow_array_map() && 2329 DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
2337 map() != GetHeap()->fixed_array_map()); 2330 map() != GetHeap()->fixed_array_map());
2338 int offset = kHeaderSize + index * kDoubleSize; 2331 int offset = kHeaderSize + index * kDoubleSize;
2339 if (std::isnan(value)) value = canonical_not_the_hole_nan_as_double(); 2332 if (std::isnan(value)) {
2333 value = std::numeric_limits<double>::quiet_NaN();
2334 }
2340 WRITE_DOUBLE_FIELD(this, offset, value); 2335 WRITE_DOUBLE_FIELD(this, offset, value);
2341 } 2336 }
2342 2337
2343 2338
2344 void FixedDoubleArray::set_the_hole(int index) { 2339 void FixedDoubleArray::set_the_hole(int index) {
2345 DCHECK(map() != GetHeap()->fixed_cow_array_map() && 2340 DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
2346 map() != GetHeap()->fixed_array_map()); 2341 map() != GetHeap()->fixed_array_map());
2347 int offset = kHeaderSize + index * kDoubleSize; 2342 int offset = kHeaderSize + index * kDoubleSize;
2348 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); 2343 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
2349 } 2344 }
(...skipping 5157 matching lines...) Expand 10 before | Expand all | Expand 10 after
7507 #undef READ_SHORT_FIELD 7502 #undef READ_SHORT_FIELD
7508 #undef WRITE_SHORT_FIELD 7503 #undef WRITE_SHORT_FIELD
7509 #undef READ_BYTE_FIELD 7504 #undef READ_BYTE_FIELD
7510 #undef WRITE_BYTE_FIELD 7505 #undef WRITE_BYTE_FIELD
7511 #undef NOBARRIER_READ_BYTE_FIELD 7506 #undef NOBARRIER_READ_BYTE_FIELD
7512 #undef NOBARRIER_WRITE_BYTE_FIELD 7507 #undef NOBARRIER_WRITE_BYTE_FIELD
7513 7508
7514 } } // namespace v8::internal 7509 } } // namespace v8::internal
7515 7510
7516 #endif // V8_OBJECTS_INL_H_ 7511 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698