comparison src/cpu/x86/vm/stubGenerator_x86_32.cpp @ 11080:b800986664f4

7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32 Summary: add intrinsics using new instruction to interpreter, C1, C2, for suitable x86; add test Reviewed-by: kvn, twisti
author drchase
date Tue, 02 Jul 2013 20:42:12 -0400
parents ef57c43512d6
children 980532a806a5
comparison
equal deleted inserted replaced
11079:738e04fb1232 11080:b800986664f4
1 /* 1 /*
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
2711 __ jmp(L_exit); 2711 __ jmp(L_exit);
2712 2712
2713 return start; 2713 return start;
2714 } 2714 }
2715 2715
2716 /**
2717 * Arguments:
2718 *
2719 * Inputs:
2720 * rsp(4) - int crc
2721 * rsp(8) - byte* buf
2722 * rsp(12) - int length
2723 *
2724 * Ouput:
2725 * rax - int crc result
2726 */
2727 address generate_updateBytesCRC32() {
2728 assert(UseCRC32Intrinsics, "need AVX and CLMUL instructions");
2729
2730 __ align(CodeEntryAlignment);
2731 StubCodeMark mark(this, "StubRoutines", "updateBytesCRC32");
2732
2733 address start = __ pc();
2734
2735 const Register crc = rdx; // crc
2736 const Register buf = rsi; // source java byte array address
2737 const Register len = rcx; // length
2738 const Register table = rdi; // crc_table address (reuse register)
2739 const Register tmp = rbx;
2740 assert_different_registers(crc, buf, len, table, tmp, rax);
2741
2742 BLOCK_COMMENT("Entry:");
2743 __ enter(); // required for proper stackwalking of RuntimeStub frame
2744 __ push(rsi);
2745 __ push(rdi);
2746 __ push(rbx);
2747
2748 Address crc_arg(rbp, 8 + 0);
2749 Address buf_arg(rbp, 8 + 4);
2750 Address len_arg(rbp, 8 + 8);
2751
2752 // Load up:
2753 __ movl(crc, crc_arg);
2754 __ movptr(buf, buf_arg);
2755 __ movl(len, len_arg);
2756
2757 __ kernel_crc32(crc, buf, len, table, tmp);
2758
2759 __ movl(rax, crc);
2760 __ pop(rbx);
2761 __ pop(rdi);
2762 __ pop(rsi);
2763 __ leave(); // required for proper stackwalking of RuntimeStub frame
2764 __ ret(0);
2765
2766 return start;
2767 }
2768
2716 2769
2717 public: 2770 public:
2718 // Information about frame layout at time of blocking runtime call. 2771 // Information about frame layout at time of blocking runtime call.
2719 // Note that we only have to preserve callee-saved registers since 2772 // Note that we only have to preserve callee-saved registers since
2720 // the compilers are responsible for supplying a continuation point 2773 // the compilers are responsible for supplying a continuation point
2885 StubRoutines::_d2l_wrapper = generate_d2i_wrapper(T_LONG, 2938 StubRoutines::_d2l_wrapper = generate_d2i_wrapper(T_LONG,
2886 CAST_FROM_FN_PTR(address, SharedRuntime::d2l)); 2939 CAST_FROM_FN_PTR(address, SharedRuntime::d2l));
2887 2940
2888 // Build this early so it's available for the interpreter 2941 // Build this early so it's available for the interpreter
2889 StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError)); 2942 StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError));
2943
2944 if (UseCRC32Intrinsics) {
2945 // set table address before stub generation which use it
2946 StubRoutines::_crc_table_adr = (address)StubRoutines::x86::_crc_table;
2947 StubRoutines::_updateBytesCRC32 = generate_updateBytesCRC32();
2948 }
2890 } 2949 }
2891 2950
2892 2951
2893 void generate_all() { 2952 void generate_all() {
2894 // Generates all stubs and initializes the entry points 2953 // Generates all stubs and initializes the entry points