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

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 863633002: Use signaling NaN for holes in fixed double arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Restore SSE2 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/division-by-constant.h" 10 #include "src/base/division-by-constant.h"
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 668
669 669
670 void MacroAssembler::StoreNumberToDoubleElements( 670 void MacroAssembler::StoreNumberToDoubleElements(
671 Register maybe_number, 671 Register maybe_number,
672 Register elements, 672 Register elements,
673 Register key, 673 Register key,
674 Register scratch1, 674 Register scratch1,
675 XMMRegister scratch2, 675 XMMRegister scratch2,
676 Label* fail, 676 Label* fail,
677 int elements_offset) { 677 int elements_offset) {
678 Label smi_value, done, maybe_nan, not_nan, is_nan, have_double_value; 678 Label smi_value, done;
679 JumpIfSmi(maybe_number, &smi_value, Label::kNear); 679 JumpIfSmi(maybe_number, &smi_value, Label::kNear);
680 680
681 CheckMap(maybe_number, 681 CheckMap(maybe_number,
682 isolate()->factory()->heap_number_map(), 682 isolate()->factory()->heap_number_map(),
683 fail, 683 fail,
684 DONT_DO_SMI_CHECK); 684 DONT_DO_SMI_CHECK);
685 685
686 // Double value, canonicalize NaN. 686 // Double value, turn potential sNaN into qNaN.
687 uint32_t offset = HeapNumber::kValueOffset + sizeof(kHoleNanLower32); 687 Move(scratch2, 1.0);
688 cmp(FieldOperand(maybe_number, offset), 688 mulsd(scratch2, FieldOperand(maybe_number, HeapNumber::kValueOffset));
689 Immediate(kNaNOrInfinityLowerBoundUpper32)); 689 jmp(&done, Label::kNear);
690 j(greater_equal, &maybe_nan, Label::kNear);
691
692 bind(&not_nan);
693 ExternalReference canonical_nan_reference =
694 ExternalReference::address_of_canonical_non_hole_nan();
695 movsd(scratch2, FieldOperand(maybe_number, HeapNumber::kValueOffset));
696 bind(&have_double_value);
697 movsd(FieldOperand(elements, key, times_4,
698 FixedDoubleArray::kHeaderSize - elements_offset),
699 scratch2);
700 jmp(&done);
701
702 bind(&maybe_nan);
703 // Could be NaN or Infinity. If fraction is not zero, it's NaN, otherwise
704 // it's an Infinity, and the non-NaN code path applies.
705 j(greater, &is_nan, Label::kNear);
706 cmp(FieldOperand(maybe_number, HeapNumber::kValueOffset), Immediate(0));
707 j(zero, &not_nan);
708 bind(&is_nan);
709 movsd(scratch2, Operand::StaticVariable(canonical_nan_reference));
710 jmp(&have_double_value, Label::kNear);
711 690
712 bind(&smi_value); 691 bind(&smi_value);
713 // Value is a smi. Convert to a double and store. 692 // Value is a smi. Convert to a double and store.
714 // Preserve original value. 693 // Preserve original value.
715 mov(scratch1, maybe_number); 694 mov(scratch1, maybe_number);
716 SmiUntag(scratch1); 695 SmiUntag(scratch1);
717 Cvtsi2sd(scratch2, scratch1); 696 Cvtsi2sd(scratch2, scratch1);
697 bind(&done);
718 movsd(FieldOperand(elements, key, times_4, 698 movsd(FieldOperand(elements, key, times_4,
719 FixedDoubleArray::kHeaderSize - elements_offset), 699 FixedDoubleArray::kHeaderSize - elements_offset),
720 scratch2); 700 scratch2);
721 bind(&done);
722 } 701 }
723 702
724 703
725 void MacroAssembler::CompareMap(Register obj, Handle<Map> map) { 704 void MacroAssembler::CompareMap(Register obj, Handle<Map> map) {
726 cmp(FieldOperand(obj, HeapObject::kMapOffset), map); 705 cmp(FieldOperand(obj, HeapObject::kMapOffset), map);
727 } 706 }
728 707
729 708
730 void MacroAssembler::CheckMap(Register obj, 709 void MacroAssembler::CheckMap(Register obj,
731 Handle<Map> map, 710 Handle<Map> map,
(...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after
3287 if (mag.shift > 0) sar(edx, mag.shift); 3266 if (mag.shift > 0) sar(edx, mag.shift);
3288 mov(eax, dividend); 3267 mov(eax, dividend);
3289 shr(eax, 31); 3268 shr(eax, 31);
3290 add(edx, eax); 3269 add(edx, eax);
3291 } 3270 }
3292 3271
3293 3272
3294 } } // namespace v8::internal 3273 } } // namespace v8::internal
3295 3274
3296 #endif // V8_TARGET_ARCH_IA32 3275 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698