提交 6a828813 编写于 作者: O ogatak
上级 f71d6ce9
...@@ -2000,7 +2000,8 @@ class Assembler : public AbstractAssembler { ...@@ -2000,7 +2000,8 @@ class Assembler : public AbstractAssembler {
inline void vsbox( VectorRegister d, VectorRegister a); inline void vsbox( VectorRegister d, VectorRegister a);
// SHA (introduced with Power 8) // SHA (introduced with Power 8)
// Not yet implemented. inline void vshasigmad(VectorRegister d, VectorRegister a, bool st, int six);
inline void vshasigmaw(VectorRegister d, VectorRegister a, bool st, int six);
// Vector Binary Polynomial Multiplication (introduced with Power 8) // Vector Binary Polynomial Multiplication (introduced with Power 8)
inline void vpmsumb( VectorRegister d, VectorRegister a, VectorRegister b); inline void vpmsumb( VectorRegister d, VectorRegister a, VectorRegister b);
...@@ -2096,6 +2097,10 @@ class Assembler : public AbstractAssembler { ...@@ -2096,6 +2097,10 @@ class Assembler : public AbstractAssembler {
inline void lvsl( VectorRegister d, Register s2); inline void lvsl( VectorRegister d, Register s2);
inline void lvsr( VectorRegister d, Register s2); inline void lvsr( VectorRegister d, Register s2);
// Endianess specific concatenation of 2 loaded vectors.
inline void load_perm(VectorRegister perm, Register addr);
inline void vec_perm(VectorRegister first_dest, VectorRegister second, VectorRegister perm);
// RegisterOrConstant versions. // RegisterOrConstant versions.
// These emitters choose between the versions using two registers and // These emitters choose between the versions using two registers and
// those with register and immediate, depending on the content of roc. // those with register and immediate, depending on the content of roc.
......
...@@ -789,7 +789,8 @@ inline void Assembler::vncipherlast(VectorRegister d, VectorRegister a, VectorRe ...@@ -789,7 +789,8 @@ inline void Assembler::vncipherlast(VectorRegister d, VectorRegister a, VectorRe
inline void Assembler::vsbox( VectorRegister d, VectorRegister a) { emit_int32( VSBOX_OPCODE | vrt(d) | vra(a) ); } inline void Assembler::vsbox( VectorRegister d, VectorRegister a) { emit_int32( VSBOX_OPCODE | vrt(d) | vra(a) ); }
// SHA (introduced with Power 8) // SHA (introduced with Power 8)
// Not yet implemented. inline void Assembler::vshasigmad(VectorRegister d, VectorRegister a, bool st, int six) { emit_int32( VSHASIGMAD_OPCODE | vrt(d) | vra(a) | vst(st) | vsix(six)); }
inline void Assembler::vshasigmaw(VectorRegister d, VectorRegister a, bool st, int six) { emit_int32( VSHASIGMAW_OPCODE | vrt(d) | vra(a) | vst(st) | vsix(six)); }
// Vector Binary Polynomial Multiplication (introduced with Power 8) // Vector Binary Polynomial Multiplication (introduced with Power 8)
inline void Assembler::vpmsumb( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VPMSUMB_OPCODE | vrt(d) | vra(a) | vrb(b)); } inline void Assembler::vpmsumb( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VPMSUMB_OPCODE | vrt(d) | vra(a) | vrb(b)); }
...@@ -887,6 +888,22 @@ inline void Assembler::stvxl( VectorRegister d, Register s2) { emit_int32( STVXL ...@@ -887,6 +888,22 @@ inline void Assembler::stvxl( VectorRegister d, Register s2) { emit_int32( STVXL
inline void Assembler::lvsl( VectorRegister d, Register s2) { emit_int32( LVSL_OPCODE | vrt(d) | rb(s2)); } inline void Assembler::lvsl( VectorRegister d, Register s2) { emit_int32( LVSL_OPCODE | vrt(d) | rb(s2)); }
inline void Assembler::lvsr( VectorRegister d, Register s2) { emit_int32( LVSR_OPCODE | vrt(d) | rb(s2)); } inline void Assembler::lvsr( VectorRegister d, Register s2) { emit_int32( LVSR_OPCODE | vrt(d) | rb(s2)); }
inline void Assembler::load_perm(VectorRegister perm, Register addr) {
#if defined(VM_LITTLE_ENDIAN)
lvsr(perm, addr);
#else
lvsl(perm, addr);
#endif
}
inline void Assembler::vec_perm(VectorRegister first_dest, VectorRegister second, VectorRegister perm) {
#if defined(VM_LITTLE_ENDIAN)
vperm(first_dest, second, first_dest, perm);
#else
vperm(first_dest, first_dest, second, perm);
#endif
}
inline void Assembler::load_const(Register d, void* x, Register tmp) { inline void Assembler::load_const(Register d, void* x, Register tmp) {
load_const(d, (long)x, tmp); load_const(d, (long)x, tmp);
} }
......
...@@ -667,6 +667,40 @@ class MacroAssembler: public Assembler { ...@@ -667,6 +667,40 @@ class MacroAssembler: public Assembler {
void kernel_crc32_singleByte(Register crc, Register buf, Register len, Register table, Register tmp); void kernel_crc32_singleByte(Register crc, Register buf, Register len, Register table, Register tmp);
// SHA-2 auxiliary functions and public interfaces
private:
void sha256_deque(const VectorRegister src,
const VectorRegister dst1, const VectorRegister dst2, const VectorRegister dst3);
void sha256_load_h_vec(const VectorRegister a, const VectorRegister e, const Register hptr);
void sha256_round(const VectorRegister* hs, const int total_hs, int& h_cnt, const VectorRegister kpw);
void sha256_load_w_plus_k_vec(const Register buf_in, const VectorRegister* ws,
const int total_ws, const Register k, const VectorRegister* kpws,
const int total_kpws);
void sha256_calc_4w(const VectorRegister w0, const VectorRegister w1,
const VectorRegister w2, const VectorRegister w3, const VectorRegister kpw0,
const VectorRegister kpw1, const VectorRegister kpw2, const VectorRegister kpw3,
const Register j, const Register k);
void sha256_update_sha_state(const VectorRegister a, const VectorRegister b,
const VectorRegister c, const VectorRegister d, const VectorRegister e,
const VectorRegister f, const VectorRegister g, const VectorRegister h,
const Register hptr);
void sha512_load_w_vec(const Register buf_in, const VectorRegister* ws, const int total_ws);
void sha512_update_sha_state(const Register state, const VectorRegister* hs, const int total_hs);
void sha512_round(const VectorRegister* hs, const int total_hs, int& h_cnt, const VectorRegister kpw);
void sha512_load_h_vec(const Register state, const VectorRegister* hs, const int total_hs);
void sha512_calc_2w(const VectorRegister w0, const VectorRegister w1,
const VectorRegister w2, const VectorRegister w3,
const VectorRegister w4, const VectorRegister w5,
const VectorRegister w6, const VectorRegister w7,
const VectorRegister kpw0, const VectorRegister kpw1, const Register j,
const VectorRegister vRb, const Register k);
public:
void sha256(bool multi_block);
void sha512(bool multi_block);
// //
// Debugging // Debugging
// //
......
此差异已折叠。
...@@ -2652,6 +2652,28 @@ class StubGenerator: public StubCodeGenerator { ...@@ -2652,6 +2652,28 @@ class StubGenerator: public StubCodeGenerator {
return start; return start;
} }
address generate_sha256_implCompress(bool multi_block, const char *name) {
assert(UseSHA, "need SHA instructions");
StubCodeMark mark(this, "StubRoutines", name);
address start = __ function_entry();
__ sha256 (multi_block);
__ blr();
return start;
}
address generate_sha512_implCompress(bool multi_block, const char *name) {
assert(UseSHA, "need SHA instructions");
StubCodeMark mark(this, "StubRoutines", name);
address start = __ function_entry();
__ sha512 (multi_block);
__ blr();
return start;
}
void generate_arraycopy_stubs() { void generate_arraycopy_stubs() {
// Note: the disjoint stubs must be generated first, some of // Note: the disjoint stubs must be generated first, some of
// the conjoint stubs use them. // the conjoint stubs use them.
...@@ -2881,6 +2903,15 @@ class StubGenerator: public StubCodeGenerator { ...@@ -2881,6 +2903,15 @@ class StubGenerator: public StubCodeGenerator {
StubRoutines::_montgomerySquare StubRoutines::_montgomerySquare
= CAST_FROM_FN_PTR(address, SharedRuntime::montgomery_square); = CAST_FROM_FN_PTR(address, SharedRuntime::montgomery_square);
} }
if (UseSHA256Intrinsics) {
StubRoutines::_sha256_implCompress = generate_sha256_implCompress(false, "sha256_implCompress");
StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB");
}
if (UseSHA512Intrinsics) {
StubRoutines::_sha512_implCompress = generate_sha512_implCompress(false, "sha512_implCompress");
StubRoutines::_sha512_implCompressMB = generate_sha512_implCompress(true, "sha512_implCompressMB");
}
} }
public: public:
......
...@@ -34,7 +34,7 @@ static bool returns_to_call_stub(address return_pc) { return return_pc == _call_ ...@@ -34,7 +34,7 @@ static bool returns_to_call_stub(address return_pc) { return return_pc == _call_
enum platform_dependent_constants { enum platform_dependent_constants {
code_size1 = 20000, // simply increase if too small (assembler will crash if too small) code_size1 = 20000, // simply increase if too small (assembler will crash if too small)
code_size2 = 20000 // simply increase if too small (assembler will crash if too small) code_size2 = 22000 // simply increase if too small (assembler will crash if too small)
}; };
// CRC32 Intrinsics. // CRC32 Intrinsics.
......
...@@ -110,7 +110,7 @@ void VM_Version::initialize() { ...@@ -110,7 +110,7 @@ void VM_Version::initialize() {
// Create and print feature-string. // Create and print feature-string.
char buf[(num_features+1) * 16]; // Max 16 chars per feature. char buf[(num_features+1) * 16]; // Max 16 chars per feature.
jio_snprintf(buf, sizeof(buf), jio_snprintf(buf, sizeof(buf),
"ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s", "ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
(has_fsqrt() ? " fsqrt" : ""), (has_fsqrt() ? " fsqrt" : ""),
(has_isel() ? " isel" : ""), (has_isel() ? " isel" : ""),
(has_lxarxeh() ? " lxarxeh" : ""), (has_lxarxeh() ? " lxarxeh" : ""),
...@@ -124,7 +124,8 @@ void VM_Version::initialize() { ...@@ -124,7 +124,8 @@ void VM_Version::initialize() {
(has_vcipher() ? " aes" : ""), (has_vcipher() ? " aes" : ""),
(has_vpmsumb() ? " vpmsumb" : ""), (has_vpmsumb() ? " vpmsumb" : ""),
(has_mfdscr() ? " mfdscr" : ""), (has_mfdscr() ? " mfdscr" : ""),
(has_vsx() ? " vsx" : "") (has_vsx() ? " vsx" : ""),
(has_vshasig() ? " sha" : "")
// Make sure number of %s matches num_features! // Make sure number of %s matches num_features!
); );
_features_str = strdup(buf); _features_str = strdup(buf);
...@@ -206,17 +207,43 @@ void VM_Version::initialize() { ...@@ -206,17 +207,43 @@ void VM_Version::initialize() {
} }
#endif #endif
if (UseSHA) { if (has_vshasig()) {
warning("SHA instructions are not available on this CPU"); if (FLAG_IS_DEFAULT(UseSHA)) {
UseSHA = true;
}
} else if (UseSHA) {
if (!FLAG_IS_DEFAULT(UseSHA))
warning("SHA instructions are not available on this CPU");
FLAG_SET_DEFAULT(UseSHA, false); FLAG_SET_DEFAULT(UseSHA, false);
} }
if (UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics) {
warning("SHA intrinsics are not available on this CPU"); if (UseSHA1Intrinsics) {
warning("Intrinsics for SHA-1 crypto hash functions not available on this CPU.");
FLAG_SET_DEFAULT(UseSHA1Intrinsics, false); FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
}
if (UseSHA && has_vshasig()) {
if (FLAG_IS_DEFAULT(UseSHA256Intrinsics)) {
FLAG_SET_DEFAULT(UseSHA256Intrinsics, true);
}
} else if (UseSHA256Intrinsics) {
warning("Intrinsics for SHA-224 and SHA-256 crypto hash functions not available on this CPU.");
FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
}
if (UseSHA && has_vshasig()) {
if (FLAG_IS_DEFAULT(UseSHA512Intrinsics)) {
FLAG_SET_DEFAULT(UseSHA512Intrinsics, true);
}
} else if (UseSHA512Intrinsics) {
warning("Intrinsics for SHA-384 and SHA-512 crypto hash functions not available on this CPU.");
FLAG_SET_DEFAULT(UseSHA512Intrinsics, false); FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
} }
if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) {
FLAG_SET_DEFAULT(UseSHA, false);
}
if (FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) { if (FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) {
UseMontgomeryMultiplyIntrinsic = true; UseMontgomeryMultiplyIntrinsic = true;
} }
...@@ -503,6 +530,7 @@ void VM_Version::determine_features() { ...@@ -503,6 +530,7 @@ void VM_Version::determine_features() {
a->vpmsumb(VR0, VR1, VR2); // code[12] -> vpmsumb a->vpmsumb(VR0, VR1, VR2); // code[12] -> vpmsumb
a->mfdscr(R0); // code[13] -> mfdscr a->mfdscr(R0); // code[13] -> mfdscr
a->lxvd2x(VSR0, R3_ARG1); // code[14] -> vsx a->lxvd2x(VSR0, R3_ARG1); // code[14] -> vsx
a->vshasigmaw(VR0, VR1, 1, 0xF); // code[15] -> vshasig
a->blr(); a->blr();
// Emit function to set one cache line to zero. Emit function descriptor and get pointer to it. // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it.
...@@ -551,6 +579,7 @@ void VM_Version::determine_features() { ...@@ -551,6 +579,7 @@ void VM_Version::determine_features() {
if (code[feature_cntr++]) features |= vpmsumb_m; if (code[feature_cntr++]) features |= vpmsumb_m;
if (code[feature_cntr++]) features |= mfdscr_m; if (code[feature_cntr++]) features |= mfdscr_m;
if (code[feature_cntr++]) features |= vsx_m; if (code[feature_cntr++]) features |= vsx_m;
if (code[feature_cntr++]) features |= vshasig_m;
// Print the detection code. // Print the detection code.
if (PrintAssembly) { if (PrintAssembly) {
......
...@@ -47,6 +47,7 @@ protected: ...@@ -47,6 +47,7 @@ protected:
vpmsumb, vpmsumb,
mfdscr, mfdscr,
vsx, vsx,
vshasig,
num_features // last entry to count features num_features // last entry to count features
}; };
enum Feature_Flag_Set { enum Feature_Flag_Set {
...@@ -63,6 +64,7 @@ protected: ...@@ -63,6 +64,7 @@ protected:
dcba_m = (1 << dcba ), dcba_m = (1 << dcba ),
lqarx_m = (1 << lqarx ), lqarx_m = (1 << lqarx ),
vcipher_m = (1 << vcipher), vcipher_m = (1 << vcipher),
vshasig_m = (1 << vshasig),
vpmsumb_m = (1 << vpmsumb), vpmsumb_m = (1 << vpmsumb),
mfdscr_m = (1 << mfdscr ), mfdscr_m = (1 << mfdscr ),
vsx_m = (1 << vsx ), vsx_m = (1 << vsx ),
...@@ -99,6 +101,7 @@ public: ...@@ -99,6 +101,7 @@ public:
static bool has_vpmsumb() { return (_features & vpmsumb_m) != 0; } static bool has_vpmsumb() { return (_features & vpmsumb_m) != 0; }
static bool has_mfdscr() { return (_features & mfdscr_m) != 0; } static bool has_mfdscr() { return (_features & mfdscr_m) != 0; }
static bool has_vsx() { return (_features & vsx_m) != 0; } static bool has_vsx() { return (_features & vsx_m) != 0; }
static bool has_vshasig() { return (_features & vshasig_m) != 0; }
static const char* cpu_features() { return _features_str; } static const char* cpu_features() { return _features_str; }
......
/* /*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -6759,10 +6759,18 @@ bool LibraryCallKit::inline_sha_implCompressMB(Node* digestBase_obj, ciInstanceK ...@@ -6759,10 +6759,18 @@ bool LibraryCallKit::inline_sha_implCompressMB(Node* digestBase_obj, ciInstanceK
if (state == NULL) return false; if (state == NULL) return false;
// Call the stub. // Call the stub.
Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, Node *call;
OptoRuntime::digestBase_implCompressMB_Type(), if (CCallingConventionRequiresIntsAsLongs) {
stubAddr, stubName, TypePtr::BOTTOM, call = make_runtime_call(RC_LEAF|RC_NO_FP,
src_start, state, ofs, limit); OptoRuntime::digestBase_implCompressMB_Type(),
stubAddr, stubName, TypePtr::BOTTOM,
src_start, state, ofs XTOP, limit XTOP);
} else {
call = make_runtime_call(RC_LEAF|RC_NO_FP,
OptoRuntime::digestBase_implCompressMB_Type(),
stubAddr, stubName, TypePtr::BOTTOM,
src_start, state, ofs, limit);
}
// return ofs (int) // return ofs (int)
Node* result = _gvn.transform(new (C) ProjNode(call, TypeFunc::Parms)); Node* result = _gvn.transform(new (C) ProjNode(call, TypeFunc::Parms));
set_result(result); set_result(result);
......
/* /*
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -930,12 +930,24 @@ const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type() { ...@@ -930,12 +930,24 @@ const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type() {
// create input type (domain) // create input type (domain)
int num_args = 4; int num_args = 4;
int argcnt = num_args; int argcnt = num_args;
if(CCallingConventionRequiresIntsAsLongs) {
argcnt += 2;
}
const Type** fields = TypeTuple::fields(argcnt); const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms; int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // buf if(CCallingConventionRequiresIntsAsLongs) {
fields[argp++] = TypePtr::NOTNULL; // state fields[argp++] = TypePtr::NOTNULL; // buf
fields[argp++] = TypeInt::INT; // ofs fields[argp++] = TypePtr::NOTNULL; // state
fields[argp++] = TypeInt::INT; // limit fields[argp++] = TypeLong::LONG; // ofs
fields[argp++] = Type::HALF;
fields[argp++] = TypeLong::LONG; // limit
fields[argp++] = Type::HALF;
} else {
fields[argp++] = TypePtr::NOTNULL; // buf
fields[argp++] = TypePtr::NOTNULL; // state
fields[argp++] = TypeInt::INT; // ofs
fields[argp++] = TypeInt::INT; // limit
}
assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
......
...@@ -36,7 +36,8 @@ public class GenericTestCaseForOtherCPU extends ...@@ -36,7 +36,8 @@ public class GenericTestCaseForOtherCPU extends
public GenericTestCaseForOtherCPU(String optionName) { public GenericTestCaseForOtherCPU(String optionName) {
// Execute the test case on any CPU except SPARC and X86 // Execute the test case on any CPU except SPARC and X86
super(optionName, new NotPredicate(new OrPredicate(Platform::isSparc, super(optionName, new NotPredicate(new OrPredicate(Platform::isSparc,
new OrPredicate(Platform::isX64, Platform::isX86)))); new OrPredicate(Platform::isPPC,
new OrPredicate(Platform::isX64, Platform::isX86)))));
} }
@Override @Override
......
...@@ -63,12 +63,20 @@ public class IntrinsicPredicates { ...@@ -63,12 +63,20 @@ public class IntrinsicPredicates {
null); null);
public static final BooleanSupplier SHA256_INSTRUCTION_AVAILABLE public static final BooleanSupplier SHA256_INSTRUCTION_AVAILABLE
= new CPUSpecificPredicate("sparc.*", new String[] { "sha256" }, = new OrPredicate(new CPUSpecificPredicate("sparc.*", new String[] { "sha256" },
null); null),
new OrPredicate(new CPUSpecificPredicate("ppc64.*", new String[] { "sha" },
null),
new CPUSpecificPredicate("ppc64le.*", new String[] { "sha" },
null)));
public static final BooleanSupplier SHA512_INSTRUCTION_AVAILABLE public static final BooleanSupplier SHA512_INSTRUCTION_AVAILABLE
= new CPUSpecificPredicate("sparc.*", new String[] { "sha512" }, = new OrPredicate(new CPUSpecificPredicate("sparc.*", new String[] { "sha512" },
null); null),
new OrPredicate(new CPUSpecificPredicate("ppc64.*", new String[] { "sha" },
null),
new CPUSpecificPredicate("ppc64le.*", new String[] { "sha" },
null)));
public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE
= new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE, = new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册