From patchwork Thu Jul 31 11:18:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edward Nevill X-Patchwork-Id: 34579 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A166820540 for ; Thu, 31 Jul 2014 11:18:56 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id l13sf11573106iga.2 for ; Thu, 31 Jul 2014 04:18:56 -0700 (PDT) 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=cCPAX7jIF1fIKmOvTFuyuHYPPe09RK5N6hmo+SK9Tdo=; b=cll6J+jX68zbLRaMAcKRz0o9gcvjOxLLajk+A9XKAGprsT+EF3C9DnPr9MuGN/c6r9 EMr8UbFZnA3en4JTRqHlYbWzT2Zlh2/seEovQseiWpBgd7xg2DmFsgh5Xb6ee42tClDj /iBq+Vc0V1omECoKVQ+uujE6dzxCP7q5kSlVAPmqDOXyep5FpuZOt4wz870hbr8+/ZGe TySenGwmwMTfPhmqGtSAZB4fQQwKrLHqLIKlDmUrd+Yaq7BRnQsRuCaldqTtY9qT+hpd MdIH1AO51nRqz00FwWS4aPS7NmYRFDUsoimaTvgiFdFAkJDafQSNFW4sQoCcLpDjOdqz 5gDw== X-Gm-Message-State: ALoCoQnLhBrue661rmSziQLwK1jRUlSBttF7yfHebi4sgHuFF5RryiLRXAVZ8/S9pohZlT2QGZYW X-Received: by 10.50.80.111 with SMTP id q15mr4784652igx.0.1406805536185; Thu, 31 Jul 2014 04:18:56 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.133 with SMTP id b5ls804050qgb.43.gmail; Thu, 31 Jul 2014 04:18:56 -0700 (PDT) X-Received: by 10.220.49.10 with SMTP id t10mr11783890vcf.34.1406805536051; Thu, 31 Jul 2014 04:18:56 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id 6si4064352vct.68.2014.07.31.04.18.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 31 Jul 2014 04:18:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id la4so3929728vcb.33 for ; Thu, 31 Jul 2014 04:18:56 -0700 (PDT) X-Received: by 10.52.37.81 with SMTP id w17mr587220vdj.95.1406805535928; Thu, 31 Jul 2014 04:18:55 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp9850vcb; Thu, 31 Jul 2014 04:18:54 -0700 (PDT) X-Received: by 10.194.202.165 with SMTP id kj5mr16164296wjc.50.1406805534551; Thu, 31 Jul 2014 04:18:54 -0700 (PDT) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by mx.google.com with ESMTPS id xy2si10652477wjc.58.2014.07.31.04.18.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 31 Jul 2014 04:18:47 -0700 (PDT) Received-SPF: pass (google.com: domain of edward.nevill@linaro.org designates 209.85.212.181 as permitted sender) client-ip=209.85.212.181; Received: by mail-wi0-f181.google.com with SMTP id bs8so3894199wib.2 for ; Thu, 31 Jul 2014 04:18:45 -0700 (PDT) X-Received: by 10.194.202.165 with SMTP id kj5mr16162872wjc.50.1406805525174; Thu, 31 Jul 2014 04:18:45 -0700 (PDT) Received: from [10.0.7.5] ([88.98.47.97]) by mx.google.com with ESMTPSA id ex2sm19527516wic.24.2014.07.31.04.18.43 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Thu, 31 Jul 2014 04:18:44 -0700 (PDT) Message-ID: <1406805523.15691.53.camel@localhost.localdomain> Subject: JDK8: Add char_array_equals From: Edward Nevill Reply-To: edward.nevill@linaro.org To: "aarch64-port-dev@openjdk.java.net" Cc: Patch Tracking Date: Thu, 31 Jul 2014 12:18:43 +0100 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=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) 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, This is the first of three patches. This one adds support for char_array_equals, the next two will add support for encodeISOArray and indexOf. This has taken slightly longer than expected because I got sidetracked with other issues. Also, I am on holiday tomorrow so it will be next week sometime before I can generate the other two patches. All the best, Ed. --- CUT HERE --- # HG changeset patch # User Edward Nevill edward.nevill@linaro.org # Date 1406805043 -3600 # Thu Jul 31 12:10:43 2014 +0100 # Node ID a028c5a90df38cda792a68056923a0d5975e5837 # Parent 5e238903a8753fdca06994bec8b36363ae930664 Add char_array_equals intrinsic diff -r 5e238903a875 -r a028c5a90df3 src/cpu/aarch64/vm/aarch64.ad --- a/src/cpu/aarch64/vm/aarch64.ad Tue Jul 29 06:00:26 2014 -0400 +++ b/src/cpu/aarch64/vm/aarch64.ad Thu Jul 31 12:10:43 2014 +0100 @@ -11677,6 +11677,20 @@ ins_pipe(pipe_class_memory); %} +instruct array_equals(iRegP_R1 ary1, iRegP_R2 ary2, iRegI_R0 result, + iRegP_R10 tmp, rFlagsReg cr) +%{ + match(Set result (AryEq ary1 ary2)); + effect(KILL tmp, USE_KILL ary1, USE_KILL ary2, KILL cr); + + format %{ "Array Equals $ary1,ary2 -> $result // KILL $tmp" %} + ins_encode %{ + __ char_arrays_equals($ary1$$Register, $ary2$$Register, + $result$$Register, $tmp$$Register); + %} + ins_pipe(pipe_class_memory); +%} + // ============================================================================ // This name is KNOWN by the ADLC and cannot be changed. // The ADLC forces a 'TypeRawPtr::BOTTOM' output type diff -r 5e238903a875 -r a028c5a90df3 src/cpu/aarch64/vm/macroAssembler_aarch64.cpp --- a/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp Tue Jul 29 06:00:26 2014 -0400 +++ b/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp Thu Jul 31 12:10:43 2014 +0100 @@ -3512,3 +3512,71 @@ BLOCK_COMMENT("} string_equals"); } + +// Compare char[] arrays aligned to 4 bytes +void MacroAssembler::char_arrays_equals(Register ary1, Register ary2, + Register result, Register tmp1) +{ + Register cnt1 = rscratch1; + Register cnt2 = rscratch2; + Register tmp2 = rscratch2; + + Label SAME, DIFFER, NEXT, TAIL03, TAIL01; + + int length_offset = arrayOopDesc::length_offset_in_bytes(); + int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR); + + BLOCK_COMMENT("char_arrays_equals {"); + + // different until proven equal + mov(result, false); + + // same array? + cmp(ary1, ary2); + br(Assembler::EQ, SAME); + + // ne if either null + cbz(ary1, DIFFER); + cbz(ary2, DIFFER); + + // lengths ne? + ldrw(cnt1, Address(ary1, length_offset)); + ldrw(cnt2, Address(ary2, length_offset)); + cmp(cnt1, cnt2); + br(Assembler::NE, DIFFER); + + lea(ary1, Address(ary1, base_offset)); + lea(ary2, Address(ary2, base_offset)); + + subs(cnt1, cnt1, 4); + br(LT, TAIL03); + + BIND(NEXT); + ldr(tmp1, Address(post(ary1, 8))); + ldr(tmp2, Address(post(ary2, 8))); + subs(cnt1, cnt1, 4); + eor(tmp1, tmp1, tmp2); + cbnz(tmp1, DIFFER); + br(GE, NEXT); + + BIND(TAIL03); // 0-3 chars left, cnt1 = #chars left - 4 + tst(cnt1, 0b10); + br(EQ, TAIL01); + ldrw(tmp1, Address(post(ary1, 4))); + ldrw(tmp2, Address(post(ary2, 4))); + cmp(tmp1, tmp2); + br(NE, DIFFER); + BIND(TAIL01); // 0-1 chars left + tst(cnt1, 0b01); + br(EQ, SAME); + ldrh(tmp1, ary1); + ldrh(tmp2, ary2); + cmp(tmp1, tmp2); + br(NE, DIFFER); + + BIND(SAME); + mov(result, true); + BIND(DIFFER); // result already set + + BLOCK_COMMENT("} char_arrays_equals"); +} diff -r 5e238903a875 -r a028c5a90df3 src/cpu/aarch64/vm/macroAssembler_aarch64.hpp --- a/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp Tue Jul 29 06:00:26 2014 -0400 +++ b/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp Thu Jul 31 12:10:43 2014 +0100 @@ -1085,6 +1085,8 @@ void string_equals(Register str1, Register str2, Register cnt, Register result, Register tmp1); + void char_arrays_equals(Register ary1, Register ary2, + Register result, Register tmp1); }; // Used by aarch64.ad to control code generation --- CUT HERE ---