Index: src/arm/full-codegen-arm.cc |
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc |
index 8ff3e9330457826f5f202412344bc44e8680934e..b2f629b26c4cbca143eb491ed1c746d7eb4ea798 100644 |
--- a/src/arm/full-codegen-arm.cc |
+++ b/src/arm/full-codegen-arm.cc |
@@ -2183,16 +2183,43 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
ASSERT(prop != NULL); |
ASSERT(prop->key()->AsLiteral() != NULL); |
+ // If the assignment starts a block of assignments to the same object, |
+ // change to slow case to avoid the quadratic behavior of repeatedly |
+ // adding fast properties. |
+ if (expr->starts_initialization_block()) { |
+ __ push(result_register()); |
+ __ ldr(ip, MemOperand(sp, kPointerSize)); // Receiver is now under value. |
+ __ push(ip); |
+ __ CallRuntime(Runtime::kToSlowProperties, 1); |
+ __ pop(result_register()); |
+ } |
+ |
// Record source code position before IC call. |
SetSourcePosition(expr->position()); |
__ mov(r2, Operand(prop->key()->AsLiteral()->handle())); |
- __ pop(r1); |
+ // Load receiver to r1. Leave a copy in the stack if needed for turning the |
+ // receiver into fast case. |
+ if (expr->ends_initialization_block()) { |
+ __ ldr(r1, MemOperand(sp)); |
+ } else { |
+ __ pop(r1); |
+ } |
Handle<Code> ic = is_classic_mode() |
? isolate()->builtins()->StoreIC_Initialize() |
: isolate()->builtins()->StoreIC_Initialize_Strict(); |
CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); |
+ // If the assignment ends an initialization block, revert to fast case. |
+ if (expr->ends_initialization_block()) { |
+ __ push(r0); // Result of assignment, saved even if not needed. |
+ // Receiver is under the result value. |
+ __ ldr(ip, MemOperand(sp, kPointerSize)); |
+ __ push(ip); |
+ __ CallRuntime(Runtime::kToFastProperties, 1); |
+ __ pop(r0); |
+ __ Drop(1); |
+ } |
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
context()->Plug(r0); |
} |
@@ -2201,16 +2228,44 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
// Assignment to a property, using a keyed store IC. |
+ // If the assignment starts a block of assignments to the same object, |
+ // change to slow case to avoid the quadratic behavior of repeatedly |
+ // adding fast properties. |
+ if (expr->starts_initialization_block()) { |
+ __ push(result_register()); |
+ // Receiver is now under the key and value. |
+ __ ldr(ip, MemOperand(sp, 2 * kPointerSize)); |
+ __ push(ip); |
+ __ CallRuntime(Runtime::kToSlowProperties, 1); |
+ __ pop(result_register()); |
+ } |
+ |
// Record source code position before IC call. |
SetSourcePosition(expr->position()); |
__ pop(r1); // Key. |
- __ pop(r2); |
+ // Load receiver to r2. Leave a copy in the stack if needed for turning the |
+ // receiver into fast case. |
+ if (expr->ends_initialization_block()) { |
+ __ ldr(r2, MemOperand(sp)); |
+ } else { |
+ __ pop(r2); |
+ } |
Handle<Code> ic = is_classic_mode() |
? isolate()->builtins()->KeyedStoreIC_Initialize() |
: isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); |
+ // If the assignment ends an initialization block, revert to fast case. |
+ if (expr->ends_initialization_block()) { |
+ __ push(r0); // Result of assignment, saved even if not needed. |
+ // Receiver is under the result value. |
+ __ ldr(ip, MemOperand(sp, kPointerSize)); |
+ __ push(ip); |
+ __ CallRuntime(Runtime::kToFastProperties, 1); |
+ __ pop(r0); |
+ __ Drop(1); |
+ } |
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
context()->Plug(r0); |
} |
@@ -2674,31 +2729,26 @@ void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( |
__ b(eq, if_false); |
// Look for valueOf symbol in the descriptor array, and indicate false if |
- // 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(r3, r1); |
- __ cmp(r3, Operand(0)); |
- __ b(eq, &done); |
- |
- __ LoadInstanceDescriptors(r1, r4, r2); |
- // r4: descriptor array. |
- // r3: valid entries in the descriptor array. |
+ // found. The type is not checked, so if it is a transition it is a false |
+ // negative. |
+ __ LoadInstanceDescriptors(r1, r4, r3); |
+ __ ldr(r3, FieldMemOperand(r4, FixedArray::kLengthOffset)); |
+ // r4: descriptor array |
+ // r3: length of descriptor array |
+ // Calculate the end of the descriptor array. |
STATIC_ASSERT(kSmiTag == 0); |
STATIC_ASSERT(kSmiTagSize == 1); |
STATIC_ASSERT(kPointerSize == 4); |
- __ mov(ip, Operand(DescriptorArray::kDescriptorSize)); |
- __ mul(r3, r3, ip); |
- // Calculate location of the first key name. |
- __ add(r4, r4, Operand(DescriptorArray::kFirstOffset - kHeapObjectTag)); |
- // Calculate the end of the descriptor array. |
- __ mov(r2, r4); |
+ __ add(r2, r4, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
__ add(r2, r2, Operand(r3, LSL, kPointerSizeLog2 - kSmiTagSize)); |
+ // Calculate location of the first key name. |
+ __ add(r4, |
+ r4, |
+ Operand(DescriptorArray::kFirstOffset - kHeapObjectTag)); |
// Loop through all the keys in the descriptor array. If one of these is the |
// symbol valueOf the result is false. |
+ Label entry, loop; |
// The use of ip to store the valueOf symbol asumes that it is not otherwise |
// used in the loop below. |
__ mov(ip, Operand(FACTORY->value_of_symbol())); |
@@ -2712,8 +2762,7 @@ void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( |
__ cmp(r4, Operand(r2)); |
__ b(ne, &loop); |
- __ bind(&done); |
- // If a valueOf property is not found on the object check that its |
+ // If a valueOf property is not found on the object check that it's |
// prototype is the un-modified String prototype. If not result is false. |
__ ldr(r2, FieldMemOperand(r1, Map::kPrototypeOffset)); |
__ JumpIfSmi(r2, if_false); |