Index: src/x64/full-codegen-x64.cc |
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc |
index 5e306dda57dc5b694281d2240174e522744f4958..ebd54d833ec80c4a003dd2177cb32ee1a529a931 100644 |
--- a/src/x64/full-codegen-x64.cc |
+++ b/src/x64/full-codegen-x64.cc |
@@ -2642,22 +2642,28 @@ void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( |
__ j(equal, if_false); |
// Look for valueOf symbol in the descriptor array, and indicate false if |
- // found. The type is not checked, so if it is a transition it is a false |
- // negative. |
+ // found. Since we omit an enumeration index check, if it is added via a |
+ // transition that shares its descriptor array, this is a false positive. |
+ Label entry, loop, done; |
+ |
+ // Skip loop if no descriptors are valid. |
+ __ NumberOfOwnDescriptors(rcx, rbx); |
+ __ cmpq(rcx, Immediate(0)); |
+ __ j(equal, &done); |
+ |
__ LoadInstanceDescriptors(rbx, rbx); |
- __ movq(rcx, FieldOperand(rbx, FixedArray::kLengthOffset)); |
- // rbx: descriptor array |
- // rcx: length of descriptor array |
+ // rbx: descriptor array. |
+ // rcx: valid entries in the descriptor array. |
// Calculate the end of the descriptor array. |
+ __ imul(rcx, rcx, Immediate(DescriptorArray::kDescriptorSize)); |
SmiIndex index = masm_->SmiToIndex(rdx, rcx, kPointerSizeLog2); |
__ lea(rcx, |
Operand( |
- rbx, index.reg, index.scale, FixedArray::kHeaderSize)); |
+ rbx, index.reg, index.scale, DescriptorArray::kFirstOffset)); |
// Calculate location of the first key name. |
__ addq(rbx, Immediate(DescriptorArray::kFirstOffset)); |
// Loop through all the keys in the descriptor array. If one of these is the |
// symbol valueOf the result is false. |
- Label entry, loop; |
__ jmp(&entry); |
__ bind(&loop); |
__ movq(rdx, FieldOperand(rbx, 0)); |
@@ -2668,10 +2674,11 @@ void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( |
__ cmpq(rbx, rcx); |
__ j(not_equal, &loop); |
+ __ bind(&done); |
// Reload map as register rbx was used as temporary above. |
__ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); |
- // If a valueOf property is not found on the object check that it's |
+ // If a valueOf property is not found on the object check that its |
// prototype is the un-modified String prototype. If not result is false. |
__ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); |
__ testq(rcx, Immediate(kSmiTagMask)); |