From patchwork Thu Dec 12 13:03:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edward Nevill X-Patchwork-Id: 22279 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0A04223FC9 for ; Thu, 12 Dec 2013 13:03:08 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id ht17sf657152vcb.6 for ; Thu, 12 Dec 2013 05:03:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:subject:from:reply-to:to :cc:date:organization:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=ikk+7pymttIJpIK98tgHvC5lFSRbMz9w0PaJlf6esdQ=; b=gU7UyKFjXG6ageG3u16fJWxUXkcnPlVuKnu6efIov7Xx1B0Yg2YJsbnSRT/D5c4xbn 686Kh/c8bj5ducVMtrKrFvIIVj8EF+Wcu1caKR/pq1AkSUv8gYkCy9e1gIWyP777/0Cr 7QYBgxgJ5rAE2HlIN/hDO4uzMB4YlwMNfhnE5AUnYQasSmYEgv3MTjW13fKt+Q7rmp3E YqDQeMz/YjV2uRjLEgGZTmGfn2iD5i+uQ2Li2JhW5Q6H28icvhxsaSs001438y7ir4FK DdlmX6MCVFmN3l2nOIZE409XKzxOTG1D4HlpZNe+fjUwvhEEWF4wDqzr3LR959gqM8m7 SsAw== X-Gm-Message-State: ALoCoQkxuIlUrNJB0KRtM4FTt0PxRsF6o5MIGCAb6sN9YXb8RBT9FXQX9MzK9b3DYZvZVIixJtAZ X-Received: by 10.236.21.132 with SMTP id r4mr2712362yhr.7.1386853387896; Thu, 12 Dec 2013 05:03:07 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.145 with SMTP id u17ls496125qef.42.gmail; Thu, 12 Dec 2013 05:03:07 -0800 (PST) X-Received: by 10.58.95.97 with SMTP id dj1mr3672034veb.21.1386853387715; Thu, 12 Dec 2013 05:03:07 -0800 (PST) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id mj10si7685074vcb.87.2013.12.12.05.03.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Dec 2013 05:03:07 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id db12so255356veb.36 for ; Thu, 12 Dec 2013 05:03:07 -0800 (PST) X-Received: by 10.58.235.129 with SMTP id um1mr1347353vec.17.1386853387621; Thu, 12 Dec 2013 05:03:07 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp352648vcz; Thu, 12 Dec 2013 05:03:07 -0800 (PST) X-Received: by 10.180.36.105 with SMTP id p9mr28887474wij.58.1386853385999; Thu, 12 Dec 2013 05:03:05 -0800 (PST) Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) by mx.google.com with ESMTPS id j4si319859wie.3.2013.12.12.05.03.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Dec 2013 05:03:05 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.51 is neither permitted nor denied by best guess record for domain of edward.nevill@linaro.org) client-ip=74.125.82.51; Received: by mail-wg0-f51.google.com with SMTP id b13so387786wgh.6 for ; Thu, 12 Dec 2013 05:03:05 -0800 (PST) X-Received: by 10.194.20.130 with SMTP id n2mr6683658wje.62.1386853385117; Thu, 12 Dec 2013 05:03:05 -0800 (PST) Received: from [192.168.1.112] ([213.122.173.130]) by mx.google.com with ESMTPSA id xl18sm24683298wib.9.2013.12.12.05.03.01 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Thu, 12 Dec 2013 05:03:04 -0800 (PST) Message-ID: <1386853380.1069.11.camel@localhost.localdomain> Subject: RFR: Fix out by one in writing array barriers From: Edward Nevill Reply-To: edward.nevill@linaro.org To: "aarch64-port-dev@openjdk.java.net" Cc: patches@linaro.org Date: Thu, 12 Dec 2013 13:03:00 +0000 Organization: Linaro X-Mailer: Evolution 3.8.5 (3.8.5-2.fc19) Mime-Version: 1.0 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: edward.nevill@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Hi, The following patch fixes some problems I am seeing with GC in the JTReg hotspot tests, specifically compiler/8010927/Test8010927 The problem seems to be an out by one error in gen_write_ref_array_post_barrier The original code reads __ lsr(start, start, CardTableModRefBS::card_shift); __ add(end, end, BytesPerHeapOop); __ lsr(end, end, CardTableModRefBS::card_shift); __ sub(end, end, start); // number of bytes to copy const Register count = end; // 'end' register contains bytes count now __ mov(scratch, (address)ct->byte_map_base); __ add(start, start, scratch); __ BIND(L_loop); __ strb(zr, Address(start, count)); __ subs(count, count, 1); __ br(Assembler::HI, L_loop); This seems to me to be broken. The last store in the loop is always strb zr, [start, 1] because of the BHI. However it must store to [start, 0] because for each HeapOOP it must do [base + [addr >> card_shift]] = 0 However in the above the last store is done to [base + [addr >> card_shift] + 1] = 0 The end condition of the loop should therefore be BHS, not BHI to include 0. However, this sometimes stores 1 too many (and sometimes not). The problem is the add end, end, BytesPerHeapOop which converts the inclusive pointer to an exclusive pointer. However this is not what we want. What we want is to store 0 in all the bytes in the range [base + [start >> card_shift]] to [base + [end >> card_shift]] The following patch fixes this. OK to push? Ed. --- CUT HERE --- exporting patch: # HG changeset patch # User Edward Nevill edward.nevill@linaro.org # Date 1386852655 0 # Thu Dec 12 12:50:55 2013 +0000 # Node ID 36ec6f5b872338684a26d353b77d7b747558281d # Parent 3c620760454c2c4ea1f871d178e7ca8700bf92d3 Fix out by 1 errors in writing array barriers diff -r 3c620760454c -r 36ec6f5b8723 src/cpu/aarch64/vm/stubGenerator_aarch64.cpp --- a/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp Wed Dec 11 09:06:48 2013 +0000 +++ b/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp Thu Dec 12 12:50:55 2013 +0000 @@ -905,7 +905,6 @@ Label L_loop; __ lsr(start, start, CardTableModRefBS::card_shift); - __ add(end, end, BytesPerHeapOop); __ lsr(end, end, CardTableModRefBS::card_shift); __ sub(end, end, start); // number of bytes to copy @@ -915,7 +914,7 @@ __ BIND(L_loop); __ strb(zr, Address(start, count)); __ subs(count, count, 1); - __ br(Assembler::HI, L_loop); + __ br(Assembler::HS, L_loop); } break; default: --- CUT HERE ---