From 4bc671c2b08cadccdbe63269087a37f4c402d703 Mon Sep 17 00:00:00 2001 From: "fschneider@chromium.org" Date: Thu, 23 Jun 2011 09:20:07 +0000 Subject: [PATCH] Add missing write barrier for arguments store ICs. Review URL: http://codereview.chromium.org/7207006 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8390 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/ic-arm.cc | 4 +++ src/ia32/ic-ia32.cc | 6 +++++ src/x64/ic-x64.cc | 6 +++++ test/mjsunit/arguments-escape.js | 17 +++++++++++++ test/mjsunit/regress/regress-arguments-gc.js | 37 ++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 test/mjsunit/regress/regress-arguments-gc.js diff --git a/src/arm/ic-arm.cc b/src/arm/ic-arm.cc index e312f98..09e2c5b 100644 --- a/src/arm/ic-arm.cc +++ b/src/arm/ic-arm.cc @@ -996,12 +996,16 @@ void KeyedStoreIC::GenerateNonStrictArguments(MacroAssembler* masm) { MemOperand mapped_location = GenerateMappedArgumentsLookup(masm, r2, r1, r3, r4, r5, ¬in, &slow); __ str(r0, mapped_location); + __ add(r6, r3, r5); + __ RecordWrite(r3, r6, r9); __ Ret(); __ bind(¬in); // The unmapped lookup expects that the parameter map is in r3. MemOperand unmapped_location = GenerateUnmappedArgumentsLookup(masm, r1, r3, r4, &slow); __ str(r0, unmapped_location); + __ add(r6, r3, r4); + __ RecordWrite(r3, r6, r9); __ Ret(); __ bind(&slow); GenerateMiss(masm, false); diff --git a/src/ia32/ic-ia32.cc b/src/ia32/ic-ia32.cc index 21395ab..c059d37 100644 --- a/src/ia32/ic-ia32.cc +++ b/src/ia32/ic-ia32.cc @@ -801,12 +801,18 @@ void KeyedStoreIC::GenerateNonStrictArguments(MacroAssembler* masm) { Operand mapped_location = GenerateMappedArgumentsLookup(masm, edx, ecx, ebx, edi, ¬in, &slow); __ mov(mapped_location, eax); + __ lea(ecx, mapped_location); + __ mov(edx, eax); + __ RecordWrite(ebx, ecx, edx); __ Ret(); __ bind(¬in); // The unmapped lookup expects that the parameter map is in ebx. Operand unmapped_location = GenerateUnmappedArgumentsLookup(masm, ecx, ebx, edi, &slow); __ mov(unmapped_location, eax); + __ lea(edi, unmapped_location); + __ mov(edx, eax); + __ RecordWrite(ebx, edi, edx); __ Ret(); __ bind(&slow); GenerateMiss(masm, false); diff --git a/src/x64/ic-x64.cc b/src/x64/ic-x64.cc index 1130bae..fe61cd9 100644 --- a/src/x64/ic-x64.cc +++ b/src/x64/ic-x64.cc @@ -1308,12 +1308,18 @@ void KeyedStoreIC::GenerateNonStrictArguments(MacroAssembler* masm) { Operand mapped_location = GenerateMappedArgumentsLookup( masm, rdx, rcx, rbx, rdi, r8, ¬in, &slow); __ movq(mapped_location, rax); + __ lea(r9, mapped_location); + __ movq(r8, rax); + __ RecordWrite(rbx, r9, r8); __ Ret(); __ bind(¬in); // The unmapped lookup expects that the parameter map is in rbx. Operand unmapped_location = GenerateUnmappedArgumentsLookup(masm, rcx, rbx, rdi, &slow); __ movq(unmapped_location, rax); + __ lea(r9, unmapped_location); + __ movq(r8, rax); + __ RecordWrite(rbx, r9, r8); __ Ret(); __ bind(&slow); GenerateMiss(masm, false); diff --git a/test/mjsunit/arguments-escape.js b/test/mjsunit/arguments-escape.js index cdb89ac..042100c 100644 --- a/test/mjsunit/arguments-escape.js +++ b/test/mjsunit/arguments-escape.js @@ -40,3 +40,20 @@ var baz = foo(0); baz(4); baz(5); baz(6); + +// Test writing a non-smi. +function foo2(x) { + var a = arguments; + function bar2(i) { + assertEquals(i, ++a[0]); + assertEquals(i, x); + }; + bar2(1.5); + bar2(2.5); + bar2(3.5); + return bar2; +} +var baz2 = foo2(0.5); +baz2(4.5); +baz2(5.5); +baz2(6.5); diff --git a/test/mjsunit/regress/regress-arguments-gc.js b/test/mjsunit/regress/regress-arguments-gc.js new file mode 100644 index 0000000..baa4e16 --- /dev/null +++ b/test/mjsunit/regress/regress-arguments-gc.js @@ -0,0 +1,37 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --expose-gc --nocleanup_code_caches_at_gc + +function f(x) { + gc(); + arguments[0] = {}; +} + +f(1); +f(1); +f(1); -- 2.7.4