From: lrn@chromium.org Date: Mon, 23 Aug 2010 13:58:56 +0000 (+0000) Subject: Fixed remaining bugs in COW-regexp-results. X-Git-Tag: upstream/4.7.83~21313 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d12f8f4e56ab262da57b7ec4f6e89a462138b5b;p=platform%2Fupstream%2Fv8.git Fixed remaining bugs in COW-regexp-results. Review URL: http://codereview.chromium.org/3197011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5322 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index e20be00..a6c1e78 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -5295,6 +5295,13 @@ void CodeGenerator::GenerateRegExpCloneResult(ZoneList* args) { __ cmp(r1, Operand(ip)); __ b(ne, &done); + if (FLAG_debug_code) { + __ LoadRoot(r2, Heap::kEmptyFixedArrayRootIndex); + __ ldr(ip, FieldMemOperand(r0, JSObject::kPropertiesOffset)); + __ cmp(ip, r2); + __ Check(eq, "JSRegExpResult: default map but non-empty properties."); + } + // All set, copy the contents to a new object. __ AllocateInNewSpace(JSRegExpResult::kSize, r2, @@ -5310,7 +5317,6 @@ void CodeGenerator::GenerateRegExpCloneResult(ZoneList* args) { __ ldm(ib, r0, r3.bit() | r4.bit() | r5.bit() | r6.bit() | r7.bit()); __ stm(ia, r2, r1.bit() | r3.bit() | r4.bit() | r5.bit() | r6.bit() | r7.bit()); - ASSERT(!Heap::InNewSpace(Heap::fixed_cow_array_map())); ASSERT(JSRegExp::kElementsOffset == 2 * kPointerSize); // Check whether elements array is empty fixed array, and otherwise make // it copy-on-write (it never should be empty unless someone is messing diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index dc84ff5..fb32972 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -2400,14 +2400,6 @@ void FullCodeGenerator::EmitRegExpConstructResult(ZoneList* args) { } -void FullCodeGenerator::EmitRegExpCloneResult(ZoneList* args) { - ASSERT(args->length() == 1); - VisitForValue(args->at(0), kStack); - __ CallRuntime(Runtime::kRegExpConstructResult, 1); - Apply(context_, r0); -} - - void FullCodeGenerator::EmitSwapElements(ZoneList* args) { ASSERT(args->length() == 3); VisitForValue(args->at(0), kStack); diff --git a/src/full-codegen.cc b/src/full-codegen.cc index 7f103ad..fc9fe1a 100644 --- a/src/full-codegen.cc +++ b/src/full-codegen.cc @@ -1427,6 +1427,14 @@ int FullCodeGenerator::TryCatch::Exit(int stack_depth) { return 0; } + +void FullCodeGenerator::EmitRegExpCloneResult(ZoneList* args) { + ASSERT(args->length() == 1); + VisitForValue(args->at(0), kStack); + __ CallRuntime(Runtime::kRegExpCloneResult, 1); + Apply(context_, result_register()); +} + #undef __ diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index a48c74e..ffd045c 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -7447,7 +7447,6 @@ void CodeGenerator::GenerateRegExpCloneResult(ZoneList* args) { Label empty; __ cmp(Operand(edx), Immediate(Factory::empty_fixed_array())); __ j(equal, &empty); - ASSERT(!Heap::InNewSpace(Heap::fixed_cow_array_map())); __ mov(FieldOperand(edx, HeapObject::kMapOffset), Immediate(Factory::fixed_cow_array_map())); __ bind(&empty); diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index 48b1ddf..bd6ab14 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -2410,14 +2410,6 @@ void FullCodeGenerator::EmitRegExpConstructResult(ZoneList* args) { } -void FullCodeGenerator::EmitRegExpCloneResult(ZoneList* args) { - ASSERT(args->length() == 1); - VisitForValue(args->at(0), kStack); - __ CallRuntime(Runtime::kRegExpCloneResult, 1); - Apply(context_, eax); -} - - void FullCodeGenerator::EmitSwapElements(ZoneList* args) { ASSERT(args->length() == 3); VisitForValue(args->at(0), kStack); diff --git a/src/runtime.cc b/src/runtime.cc index afb0df0..d46b390 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -1403,8 +1403,6 @@ static Object* Runtime_RegExpCloneResult(Arguments args) { // Copy JSObject elements as copy-on-write. FixedArray* elements = FixedArray::cast(result->elements()); if (elements != Heap::empty_fixed_array()) { - ASSERT(!Heap::InNewSpace(Heap::fixed_cow_array_map())); - // No write barrier is necessary when writing old-space pointer. elements->set_map(Heap::fixed_cow_array_map()); } new_array->set_elements(elements); diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index 98dd978..0209aad 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -4833,7 +4833,7 @@ void DeferredAllocateInNewSpace::Generate() { for (int i = kNumRegs - 1; i >= 0; i--) { if (registers_to_save_ & (1 << i)) { Register save_register = { i }; - __ push(save_register); + __ pop(save_register); } } } @@ -6648,6 +6648,14 @@ void CodeGenerator::GenerateRegExpCloneResult(ZoneList* args) { __ cmpq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); __ j(not_equal, &done); + if (FLAG_debug_code) { + // Check that object really has empty properties array, as the map + // should guarantee. + __ CompareRoot(FieldOperand(rax, JSObject::kPropertiesOffset), + Heap::kEmptyFixedArrayRootIndex); + __ Check(equal, "JSRegExpResult: default map but non-empty properties."); + } + DeferredAllocateInNewSpace* allocate_fallback = new DeferredAllocateInNewSpace(JSRegExpResult::kSize, rbx, @@ -6680,7 +6688,6 @@ void CodeGenerator::GenerateRegExpCloneResult(ZoneList* args) { Label empty; __ CompareRoot(rdx, Heap::kEmptyFixedArrayRootIndex); __ j(equal, &empty); - ASSERT(!Heap::InNewSpace(Heap::fixed_cow_array_map())); __ LoadRoot(kScratchRegister, Heap::kFixedCOWArrayMapRootIndex); __ movq(FieldOperand(rdx, HeapObject::kMapOffset), kScratchRegister); __ bind(&empty); diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index 1c0f959..f273641 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -2399,14 +2399,6 @@ void FullCodeGenerator::EmitRegExpConstructResult(ZoneList* args) { } -void FullCodeGenerator::EmitRegExpCloneResult(ZoneList* args) { - ASSERT(args->length() == 1); - VisitForValue(args->at(0), kStack); - __ CallRuntime(Runtime::kRegExpCloneResult, 1); - Apply(context_, rax); -} - - void FullCodeGenerator::EmitSwapElements(ZoneList* args) { ASSERT(args->length() == 3); VisitForValue(args->at(0), kStack);