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

Unified Diff: src/code-stub-assembler.cc

Issue 2002813002: [stubs] Fix hole-related double bug in ArrayNoArgumentConstructor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/holy-double-no-arg-array.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index cf9fcb8df8baf5371af463fb1325125f24a770e7..9307b87b4bd756e12bedfac35bf5bd65d85acdb2 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -691,12 +691,35 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
elements, FixedArray::kLengthOffset,
mode == SMI_PARAMETERS ? capacity_node : SmiTag(capacity_node));
- Node* double_hole = Float64Constant(bit_cast<double>(kHoleNanInt64));
+ int const first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag;
Node* hole = HeapConstant(Handle<HeapObject>(heap->the_hole_value()));
+ Node* double_hole =
+ Is64() ? Int64Constant(kHoleNanInt64) : Int32Constant(kHoleNanLower32);
+ DCHECK_EQ(kHoleNanLower32, kHoleNanUpper32);
if (constant_capacity && capacity <= kElementLoopUnrollThreshold) {
for (int i = 0; i < capacity; ++i) {
if (is_double) {
- StoreFixedDoubleArrayElement(elements, Int32Constant(i), double_hole);
+ Node* offset = ElementOffsetFromIndex(Int32Constant(i), kind, mode,
+ first_element_offset);
+ // Don't use doubles to store the hole double, since manipulating the
+ // signaling NaN used for the hole in C++, e.g. with bit_cast, will
+ // change its value on ia32 (the x87 stack is used to return values
+ // and stores to the stack silently clear the signalling bit).
+ //
+ // TODO(danno): When we have a Float32/Float64 wrapper class that
+ // preserves double bits during manipulation, remove this code/change
+ // this to an indexed Float64 store.
+ if (Is64()) {
+ StoreNoWriteBarrier(MachineRepresentation::kWord64, elements, offset,
+ double_hole);
+ } else {
+ StoreNoWriteBarrier(MachineRepresentation::kWord32, elements, offset,
+ double_hole);
+ offset = ElementOffsetFromIndex(Int32Constant(i), kind, mode,
+ first_element_offset + kPointerSize);
+ StoreNoWriteBarrier(MachineRepresentation::kWord32, elements, offset,
+ double_hole);
+ }
} else {
StoreFixedArrayElement(elements, Int32Constant(i), hole,
SKIP_WRITE_BARRIER);
« no previous file with comments | « no previous file | test/mjsunit/holy-double-no-arg-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698