1 /*
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2016 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
2293 __ add2reg(Z_RET, (int)VM_Version::MsgDigest::_SHA512_dataBlk, srcOff); // Offset of first unprocessed byte in buffer.
2294 }
2295
2296 __ bind(rtn);
2297 __ z_br(Z_R14);
2298
2299 if (multiBlock) {
2300 __ bind(useKLMD);
2301 #if 1
2302 // Security net: this stub is believed to be called for full-sized data blocks only
2303 // NOTE:
2304 // The following code is believed to be correct, but is is not tested.
2305 __ stop_static("SHA512 stub can digest full data blocks only. Use -XX:-UseSHA as remedy.", 0);
2306 #endif
2307 }
2308
2309 return __ addr_at(start_off);
2310 }
2311
2312
2313
2314 // Arguments:
2315 // Z_ARG1 - int crc
2316 // Z_ARG2 - byte* buf
2317 // Z_ARG3 - int length (of buffer)
2318 //
2319 // Result:
2320 // Z_RET - int crc result
2321 //
2322 // Compute CRC32 function.
2323 address generate_CRC32_updateBytes(const char* name) {
2324 __ align(CodeEntryAlignment);
2325 StubCodeMark mark(this, "StubRoutines", name);
2326 unsigned int start_off = __ offset(); // Remember stub start address (is rtn value).
2327
2328 // arguments to kernel_crc32:
2329 Register crc = Z_ARG1; // Current checksum, preset by caller or result from previous call, int.
2330 Register data = Z_ARG2; // source byte array
2331 Register dataLen = Z_ARG3; // #bytes to process, int
2332 Register table = Z_ARG4; // crc table address
2333 const Register t0 = Z_R10; // work reg for kernel* emitters
2334 const Register t1 = Z_R11; // work reg for kernel* emitters
2335 const Register t2 = Z_R12; // work reg for kernel* emitters
2336 const Register t3 = Z_R13; // work reg for kernel* emitters
2337
2338 assert_different_registers(crc, data, dataLen, table);
2339
2340 // We pass these values as ints, not as longs as required by C calling convention.
2341 // Crc used as int.
2342 __ z_llgfr(dataLen, dataLen);
2343
2344 StubRoutines::zarch::generate_load_crc_table_addr(_masm, table);
2345
2346 __ resize_frame(-(6*8), Z_R0, true); // Resize frame to provide add'l space to spill 5 registers.
2347 __ z_stmg(Z_R10, Z_R13, 1*8, Z_SP); // Spill regs 10..11 to make them available as work registers.
2348 __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3);
2349 __ z_lmg(Z_R10, Z_R13, 1*8, Z_SP); // Spill regs 10..11 back from stack.
2350 __ resize_frame(+(6*8), Z_R0, true); // Resize frame to provide add'l space to spill 5 registers.
2351
2352 __ z_llgfr(Z_RET, crc); // Updated crc is function result. No copying required, just zero upper 32 bits.
2353 __ z_br(Z_R14); // Result already in Z_RET == Z_ARG1.
2354
2355 return __ addr_at(start_off);
2356 }
2357
2358
2359 // Arguments:
2360 // Z_ARG1 - x address
2361 // Z_ARG2 - x length
2362 // Z_ARG3 - y address
2363 // Z_ARG4 - y length
2364 // Z_ARG5 - z address
2365 // 160[Z_SP] - z length
2366 address generate_multiplyToLen() {
2367 __ align(CodeEntryAlignment);
2368 StubCodeMark mark(this, "StubRoutines", "multiplyToLen");
2369
2370 address start = __ pc();
2371
2372 const Register x = Z_ARG1;
2373 const Register xlen = Z_ARG2;
2405 // disadvantage of having a much more complicated generator
2406 // structure. See also comment in stubRoutines.hpp.
2407 StubRoutines::_forward_exception_entry = generate_forward_exception();
2408
2409 StubRoutines::_call_stub_entry = generate_call_stub(StubRoutines::_call_stub_return_address);
2410 StubRoutines::_catch_exception_entry = generate_catch_exception();
2411
2412 // Build this early so it's available for the interpreter.
2413 StubRoutines::_throw_StackOverflowError_entry =
2414 generate_throw_exception("StackOverflowError throw_exception",
2415 CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError), false);
2416
2417 //----------------------------------------------------------------------
2418 // Entry points that are platform specific.
2419 // Build this early so it's available for the interpreter.
2420 StubRoutines::_throw_StackOverflowError_entry =
2421 generate_throw_exception("StackOverflowError throw_exception",
2422 CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError), false);
2423
2424 if (UseCRC32Intrinsics) {
2425 // We have no CRC32 table on z/Architecture.
2426 StubRoutines::_crc_table_adr = (address)StubRoutines::zarch::_crc_table;
2427 StubRoutines::_updateBytesCRC32 = generate_CRC32_updateBytes("CRC32_updateBytes");
2428 }
2429
2430 // Comapct string intrinsics: Translate table for string inflate intrinsic. Used by trot instruction.
2431 StubRoutines::zarch::_trot_table_addr = (address)StubRoutines::zarch::_trot_table;
2432 }
2433
2434
2435 void generate_all() {
2436 // Generates all stubs and initializes the entry points.
2437
2438 StubRoutines::zarch::_partial_subtype_check = generate_partial_subtype_check();
2439
2440 // These entry points require SharedInfo::stack0 to be set up in non-core builds.
2441 StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError), false);
2442 StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError), false);
2443 StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call), false);
2444
2445 // Support for verify_oop (must happen after universe_init).
2446 StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop_subroutine();
2447
|
1 /*
2 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2016, 2017, SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
2293 __ add2reg(Z_RET, (int)VM_Version::MsgDigest::_SHA512_dataBlk, srcOff); // Offset of first unprocessed byte in buffer.
2294 }
2295
2296 __ bind(rtn);
2297 __ z_br(Z_R14);
2298
2299 if (multiBlock) {
2300 __ bind(useKLMD);
2301 #if 1
2302 // Security net: this stub is believed to be called for full-sized data blocks only
2303 // NOTE:
2304 // The following code is believed to be correct, but is is not tested.
2305 __ stop_static("SHA512 stub can digest full data blocks only. Use -XX:-UseSHA as remedy.", 0);
2306 #endif
2307 }
2308
2309 return __ addr_at(start_off);
2310 }
2311
2312
2313 /**
2314 * Arguments:
2315 *
2316 * Inputs:
2317 * Z_ARG1 - int crc
2318 * Z_ARG2 - byte* buf
2319 * Z_ARG3 - int length (of buffer)
2320 *
2321 * Result:
2322 * Z_RET - int crc result
2323 **/
2324 // Compute CRC function (generic, for all polynomials).
2325 void generate_CRC_updateBytes(const char* name, Register table, bool invertCRC) {
2326
2327 // arguments to kernel_crc32:
2328 Register crc = Z_ARG1; // Current checksum, preset by caller or result from previous call, int.
2329 Register data = Z_ARG2; // source byte array
2330 Register dataLen = Z_ARG3; // #bytes to process, int
2331 // Register table = Z_ARG4; // crc table address. Preloaded and passed in by caller.
2332 const Register t0 = Z_R10; // work reg for kernel* emitters
2333 const Register t1 = Z_R11; // work reg for kernel* emitters
2334 const Register t2 = Z_R12; // work reg for kernel* emitters
2335 const Register t3 = Z_R13; // work reg for kernel* emitters
2336
2337 assert_different_registers(crc, data, dataLen, table);
2338
2339 // We pass these values as ints, not as longs as required by C calling convention.
2340 // Crc used as int.
2341 __ z_llgfr(dataLen, dataLen);
2342
2343 __ resize_frame(-(6*8), Z_R0, true); // Resize frame to provide add'l space to spill 5 registers.
2344 __ z_stmg(Z_R10, Z_R13, 1*8, Z_SP); // Spill regs 10..11 to make them available as work registers.
2345 __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, invertCRC);
2346 __ z_lmg(Z_R10, Z_R13, 1*8, Z_SP); // Spill regs 10..11 back from stack.
2347 __ resize_frame(+(6*8), Z_R0, true); // Resize frame to provide add'l space to spill 5 registers.
2348
2349 __ z_llgfr(Z_RET, crc); // Updated crc is function result. No copying required, just zero upper 32 bits.
2350 __ z_br(Z_R14); // Result already in Z_RET == Z_ARG1.
2351 }
2352
2353
2354 // Compute CRC32 function.
2355 address generate_CRC32_updateBytes(const char* name) {
2356 __ align(CodeEntryAlignment);
2357 StubCodeMark mark(this, "StubRoutines", name);
2358 unsigned int start_off = __ offset(); // Remember stub start address (is rtn value).
2359
2360 assert(UseCRC32Intrinsics, "should not generate this stub (%s) with CRC32 intrinsics disabled", name);
2361
2362 BLOCK_COMMENT("CRC32_updateBytes {");
2363 Register table = Z_ARG4; // crc32 table address.
2364 StubRoutines::zarch::generate_load_crc_table_addr(_masm, table);
2365
2366 generate_CRC_updateBytes(name, table, true);
2367 BLOCK_COMMENT("} CRC32_updateBytes");
2368
2369 return __ addr_at(start_off);
2370 }
2371
2372
2373 // Compute CRC32C function.
2374 address generate_CRC32C_updateBytes(const char* name) {
2375 __ align(CodeEntryAlignment);
2376 StubCodeMark mark(this, "StubRoutines", name);
2377 unsigned int start_off = __ offset(); // Remember stub start address (is rtn value).
2378
2379 assert(UseCRC32CIntrinsics, "should not generate this stub (%s) with CRC32C intrinsics disabled", name);
2380
2381 BLOCK_COMMENT("CRC32C_updateBytes {");
2382 Register table = Z_ARG4; // crc32c table address.
2383 StubRoutines::zarch::generate_load_crc32c_table_addr(_masm, table);
2384
2385 generate_CRC_updateBytes(name, table, false);
2386 BLOCK_COMMENT("} CRC32C_updateBytes");
2387
2388 return __ addr_at(start_off);
2389 }
2390
2391
2392 // Arguments:
2393 // Z_ARG1 - x address
2394 // Z_ARG2 - x length
2395 // Z_ARG3 - y address
2396 // Z_ARG4 - y length
2397 // Z_ARG5 - z address
2398 // 160[Z_SP] - z length
2399 address generate_multiplyToLen() {
2400 __ align(CodeEntryAlignment);
2401 StubCodeMark mark(this, "StubRoutines", "multiplyToLen");
2402
2403 address start = __ pc();
2404
2405 const Register x = Z_ARG1;
2406 const Register xlen = Z_ARG2;
2438 // disadvantage of having a much more complicated generator
2439 // structure. See also comment in stubRoutines.hpp.
2440 StubRoutines::_forward_exception_entry = generate_forward_exception();
2441
2442 StubRoutines::_call_stub_entry = generate_call_stub(StubRoutines::_call_stub_return_address);
2443 StubRoutines::_catch_exception_entry = generate_catch_exception();
2444
2445 // Build this early so it's available for the interpreter.
2446 StubRoutines::_throw_StackOverflowError_entry =
2447 generate_throw_exception("StackOverflowError throw_exception",
2448 CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError), false);
2449
2450 //----------------------------------------------------------------------
2451 // Entry points that are platform specific.
2452 // Build this early so it's available for the interpreter.
2453 StubRoutines::_throw_StackOverflowError_entry =
2454 generate_throw_exception("StackOverflowError throw_exception",
2455 CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError), false);
2456
2457 if (UseCRC32Intrinsics) {
2458 StubRoutines::_crc_table_adr = (address)StubRoutines::zarch::_crc_table;
2459 StubRoutines::_updateBytesCRC32 = generate_CRC32_updateBytes("CRC32_updateBytes");
2460 }
2461
2462 if (UseCRC32CIntrinsics) {
2463 StubRoutines::_crc32c_table_addr = (address)StubRoutines::zarch::_crc32c_table;
2464 StubRoutines::_updateBytesCRC32C = generate_CRC32C_updateBytes("CRC32C_updateBytes");
2465 }
2466
2467 // Comapct string intrinsics: Translate table for string inflate intrinsic. Used by trot instruction.
2468 StubRoutines::zarch::_trot_table_addr = (address)StubRoutines::zarch::_trot_table;
2469 }
2470
2471
2472 void generate_all() {
2473 // Generates all stubs and initializes the entry points.
2474
2475 StubRoutines::zarch::_partial_subtype_check = generate_partial_subtype_check();
2476
2477 // These entry points require SharedInfo::stack0 to be set up in non-core builds.
2478 StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError), false);
2479 StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError), false);
2480 StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call), false);
2481
2482 // Support for verify_oop (must happen after universe_init).
2483 StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop_subroutine();
2484
|